-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
layout.grid enhancements for plotly.py to replace make_subplots #3507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yup, I agree this would be great! Subplot titles would be really handy, especially if they could be used for facet labelling somehow i.e. placed on the side as well as the top and if a subplot could have two titles, for the corner one ;) Barring that, they would still be very handy for wrapped-facet labelling |
Thanks for kicking this discussion off @jonmmease! Definitely a great set of features to have, and I think you've covered all the important functionality. SpansYour proposal works slightly differently from html tables, which seem to me the closest common analog. The difference is tables don't include entries (
In your version this would look like: colspan: [[2, 0, 1],
[0, 0, 1], // <- last one: row 1, col 2
[1, 2, 0]]
rowspan: [[2, 0, 1],
[0, 0, 1],
[1, 1, 0]]
subplots: [['xy' , null , 'x2y2'],
[null , null , 'x3y3'],
['x4y4', 'x5y5', null ]] whereas using the table analogy it would be: colspan: [[2, 1],
[ 1], // <- last (only) one: row 1, col 0
[1, 2 ]]
rowspan: [[2, 1],
[ 1],
[1, 1 ]]
subplots: [['xy' , 'x2y2'],
[ 'x3y3'],
['x4y4', 'x5y5' ]] If we're only talking about cartesian subplots, this difference doesn't matter much; these three arrays are all self-consistent either way. The table version is nice because we're not forced to add placeholder entries, we're just enumerating cells in the order we encounter them. On the other hand your version keeps the arrays rectangular, which seems easier to construct - you can make an empty array of the right dimensions, then place cells into it by putting the cell spec in the upper left corner and fill the rest of the cell with But seems to me yours has a clear advantage in referencing spanned grid cells in TitlesIf There may still be edge cases this doesn't cover. The most flexible solution of all would be annotations with Column/row widths
InsetsI agree, no need to build this into the grid, just make another pair of axes (or non-cartesian subplot) and specify |
rowspan / colspan
That's the winning argument for me. I'm voting for colspan: [[2, 0, 1],
[0, 0, 1], // <- last one: row 1, col 2
[1, 2, 0]]
rowspan: [[2, 0, 1],
[0, 0, 1],
[1, 1, 0]]
subplots: [['xy' , null , 'x2y2'],
[null , null , 'x3y3'],
['x4y4', 'x5y5', null ]] Subplot tItlesFirst referencing #2746
I think I'd vote for keeping subplot title out of Column/row widths👍 InsetsI looked through plotly/plotly.py#170 to try to find why |
I like this solution a lot, and it should be easy enough to support from plotly.py. Thanks @etpinard and @alexcjohnson for improving on my suggestion! |
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson |
Background
plotly.py has a system for building figures with subplots that predates the plotly.js
layout.grid
system for subplots. I would like to replace this custom subplot system withlayout.grid
to reduce complexity inside plotly.py and add support for all trace types (plotly.py's system only supports Cartesian subplot types). This transition will also make the integration ofpx
into plotly.py much smoother.Needs
As far as I can tell, there are two features that are implemented in plotly.py's
make_subplots
function that are not supported by layout.grid.The first two are both demonstrated in this example https://plot.ly/python/subplots/#custom-sized-subplot-with-subplot-titles.
make_subplots
allows individual axes to span multiple subplot grid entriesmake_subplots
has a system for positioning text annotations as titles for individual subplotsmake_subplots
supportscolumn_width
androw_width
arrays to support non-uniform widths of the rows and columns in the grid.make_subplots
supports the specification of insets. TBH I'm not really sure how this works and I don't know if there are any examples of this outside of the docstring. And this might not be something that makes sense to support inlayout.grid
. Here's the docstringAPI ideas
To kick things off, here's a idea for a potential plotly.js API
layout.grid.rowspan
andlayout.grid.colspan
properties that may optionally be set to 2D arrays of integers. So the example above would have a acolspan
property ofwhich would imply a
grid.subplots
property ofgrid.titles
property that is a 2D array of title strings. So the example above would have agrid.titles
property ofgrid.widths
andgrid.heights
properties that would be 1D arrays of numbers. We could internally normalize each array and use the elements to determine the width/height of each column/row.cc @nicolaskruchten
The text was updated successfully, but these errors were encountered: