| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Wonderful idea. I think the most common usecases could be implemented via gridspec. |
Sorry, something went wrong.
|
Actually capturing the common use cases is quiete easy: import matplotlib.pyplot as plt
def parase_layout(s):
s = [list(i) for i in s]
s_T = transpose_list(s)
n_cols = len(s[0])
n_rows = len(s)
added_axes = {}
for i, row in enumerate(s):
for j, ch in enumerate(row):
if not ch in added_axes:
width = n_rows-row.index(ch)-row[::-1].index(ch)
height = n_cols-s_T[j].index(ch)-s_T[j][::-1].index(ch)
added_axes[ch] = ((i,j), width, height)
return added_axes, (n_rows, n_cols)
def transpose_list(l):
return map(list, zip(*l))
def layout(s):
d, (nr, nc) = parase_layout(s)
gs = plt.GridSpec(nr, nc)
for pos, width, height in d.values():
t = gs[pos[0]:pos[0]+height, pos[1]:pos[1]+width]
plt.subplot(t)
s = ['AAB', 'AAB', 'CCC']
layout(s)
|
Sorry, something went wrong.
There was a problem hiding this comment.
Assuming the case "AaB", is the width of A and B equal or is A smaller?
Sorry, something went wrong.
|
Do the values of the chars used to describe the layout matter? I.e. what about "MPL" to produce: ┌────────┐┌────────┐┌────────┐ │ M ││ P ││ L │ │ ││ ││ │ │ ││ ││ │ └────────┘└────────┘└────────┘ What about non-latin characters, like Greek? "ΓγΔδ" |
Sorry, something went wrong.
|
@OceanWolf You're right, I don't seen any reason to not use utf8 character but the ascii restriction might make thing simpler in a first version. For your example, I think it makes sense to write A,B,C = layout("MPL") or M,P,L = layout("MPL") |
Sorry, something went wrong.
|
Great, I just love seeing code written as generically as possible. I see the hassles that firefox now have rewriting virtually their entire codebase to support languages that don't work right-to-left-top-to-bottom. It has taken them years to sort that out, and still it continues... |
Sorry, something went wrong.
There was a problem hiding this comment.
Being able to use Python triple-quoted strings here might also be nice:
layout("""
AB
CD
""")
Here, it would to s.strip().split('\n') to get to the "list of strings" as currently specified here.
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, but I'm not fan of the line return. I would prefer something like:
layout("""AB
CB""")
or maybe:
layout("AB",
"CB")
Sorry, something went wrong.
|
@mdboom Sorry, I missed you comment. I try to modify the MEP along with comments but then github interfaces hides outdated comments. The A/a thing was suggested on the mailing list but I agree it's a bit strange. We could also have keyword arguments to specify where to add colorbars but I can't think of an intuitive syntax. For your example, I would love to have: AaB CDE ┌───────┐┌─┐ ┌───────┐ │ A ││ │ │ B │ │ ││ │ │ │ │ ││ │ │ │ └───────┘└─┘ └───────┘ ┌───────┐┌───────┐┌───────┐ │ C ││ D ││ E │ │ ││ ││ │ │ ││ ││ │ └───────┘└───────┘└───────┘ |
Sorry, something went wrong.
|
If I understand how it works, the letters just group axes together with repeated letters indicating that that axes should occur larger. A "colorbar" axes (and I put that inverted commas because I don't think we should limit ourselves to just colorbars here) has a fixed width, i.e. it doesn't expand when the window expands, hence I don't see the need for letters for this type of axes. How about we use the four operator symbols (+, -, /, *) to denote fixed width axes above, below, left and right respectfully. I would imagine that these axes should eat into the space assigned. Hence ["AB/", "CD"] gives: ┌───────┐┌─┐┌────┐ │ A ││ ││ B │ │ ││ ││ │ │ ││ ││ │ └───────┘└─┘└────┘ ┌───────┐┌───────┐ │ C ││ D │ │ ││ │ │ ││ │ └───────┘└───────┘ and ["A*B", "CD"] gives either what you outlined above, or the following: ┌────┐┌─┐┌───────┐ │ A ││ ││ B │ │ ││ ││ │ │ ││ ││ │ └────┘└─┘└───────┘ ┌───────┐┌───────┐ │ C ││ D │ │ ││ │ │ ││ │ └───────┘└───────┘ Alternatively if we don't eat into the space, then ["A*B", "CDE"] gives: ┌───────┐┌─┐┌───────┐ │ A ││ ││ B │ │ ││ ││ │ │ ││ ││ │ └───────┘└─┘└───────┘ ┌───────┐ ┌───────┐┌───────┐ │ C │ │ D ││ E │ │ │ │ ││ │ │ │ │ ││ │ └───────┘ └───────┘└───────┘ |
Sorry, something went wrong.
|
But how would you specify horizontal colorbars ? |
Sorry, something went wrong.
|
@rougier to get travis happy you should make sure that MEP28.rst is included in the toc tree in https://github.com/matplotlib/matplotlib/blob/master/doc/devel/MEP/index.rst We are treating Sphinx warnings as errors when building the docs and this raises a not included warning. |
Sorry, something went wrong.
|
Implenting fixed size axes is not too hard, the problem in matplotlib is more to choose the right size. |
Sorry, something went wrong.
|
@rougier Horizontal axes would work exactly the same but using the + and - suffixes. |
Sorry, something went wrong.
|
I think all this functionality is carried out by gridspec. I'm going to close due to inactivity. Feel free to re-open if this is inappropriate... |
Sorry, something went wrong.
|
Do we want to merge not-implemented MEPs to keep a record of them? |
Sorry, something went wrong.
|
The MEP process is a bit of mystery to me. But in this case it was never merged, so I assume it was never accepted. In this case I think a little helper function could be written that wrapped GridSpec and add subplot to do what this MEP proposes. But maybe I’m missing something. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
[Work in Progress]
This is an early draft for a semi-graphical specification of subplots layout. The main idea is to use an array of strings to specify the location and relative size of subplots. Very early draft far from complete but I think feedbacks are needed at this point.