Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Revamp tls.get_subplots #170

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

Merged
etpinard merged 104 commits into master from revamp-get_subplots
Jan 13, 2015
Merged

Revamp tls.get_subplots #170

etpinard merged 104 commits into master from revamp-get_subplots
Jan 13, 2015

Conversation

@etpinard
Copy link
Contributor

@etpinard etpinard commented Dec 22, 2014

@theengineear @chriddyp

tls.get_subplots is in need of some revamping.

More info in this Asana task.

This NB shows off the new features.

Features wishlist:

  • Generate more complicated subplot arrangements e.g https://plot.ly/~etpinard/245
  • Assign shared axes
  • Set irregular horizontal and vertical spacing in-between subplots
  • Generate subscenes - subaxes subplot grid.
  • Generate insets with ease

API issue to resolve:

Solution: Enforce specs to have dimensions (rows, columns). Use None to fill in cells over row / column spans.

plotly/tools.py Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about supporting fig = tls.get_subplots(fig, **kwargs)

e.g. if someone wants to augment a already-defined figure object.

Copy link
Contributor

@theengineear theengineear Dec 22, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i maybe it would make sense as as a method of a figure?

Copy link
Contributor Author

@theengineear @chriddyp

I'd love to get some feedback before I get started. Thanks in advance.

Copy link
Contributor

@etpinard , my major two concerns are:

  • misplaced functionality, let's make sure we don't extend the use of the get_subplots function beyond it's intuited limits. (related to adding some functionality to a method of Figure OR making a new function to handle a more abstracted figure design process)
  • rather than take a complicated structure of subplots and infer locations, it might be better to allow the user to define a grid and then assign subplots to locations on the grid (like matplotlib's gridspec)

Copy link
Contributor Author

@theengineear Thanks for the insight as always.

  • Something along the lines of mpl's gridspecs is the way to go I think. I'll try to work something out today.
  • [Re making fig an argument for tls.get_subplots] You're right, it does seem a little weird. I wouldn't be opposed to making get_subplots a method of Figure, but let's leave that for a future PR.

- breaks backwards compatibility
- horz = 0.2 / columns (same as old if rows==2)
- vert = 0.3 / rows (same as old if columns==2)
- subplot domain computation are made using specs whether or not
 it is a supplied argument
- use tracers (x and y) to keep track of position
 from subplot to subplot
- cases where colspan > 1 or rowspan > 1 require more attention
- use _get_shared() to get the shared axis (if any)
- use _add_domain() to paste result into fig object
- use _fill_grid() to generate the str repr of the subplot grid
- because of new horizontal_spacing and vertical_spacing defaults
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theengineear I had to modify the computed domains. The algorithm in this branch yield slightly (slightly) different values.

Copy link
Contributor Author

@theengineear @chriddyp

I'll make an NB tomorrow showing tls.get_subplots new muscles.

Copy link
Contributor Author

FYI I found a few bugs yesterday while making the NB.

Modifs are coming.

Copy link
Contributor Author

etpinard commented Jan 9, 2015

@theengineear good call. _grid_ref and _grid_str make more sense as attributes.

Copy link
Contributor Author

etpinard commented Jan 9, 2015

@theengineear @chriddyp version bump and merge?

Copy link
Contributor

🍔 from me, but I think we should @chriddyp a little time to respond as well!

Copy link
Member

@chriddyp chriddyp Jan 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring!

Helper function to add a data traces to your figure that is bound to axes at the row, col index.
The row, col index is generated from figures created with plotly.tools.make_subplots and
can be viewed with Figure.print_grid.

Copy link
Member

chriddyp commented Jan 9, 2015

I'm gonna give this a quick spin 🚗

Copy link
Member

chriddyp commented Jan 9, 2015

(ongoing)

  • Missing trace
    image
  • TODO in the docstring:
    image
  • rightmost xaxis should prolly be on the bottom
    image
    image
  • Should we through an error if user puts {} instead of None? Is there any case where {} would be used in tandem with rowspan or colspan?
    image

Copy link
Member

@chriddyp chriddyp Jan 9, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe changed to:

stack two subplots vertically

fig = tools.get_subplots(rows=2)
fig.append_trace(Scatter(x=[1,2,3], y=[2,1,2]), row=1, col=1)

alternatively: fig['data'] += [Scatter(x=[1,2,3], y=[2,1,2], xaxis='x1', yaxis='y1')]

fig.append_trace(Scatter(x=[1,2,3], y=[2,1,2]), row=2, col=1)

alternatively: fig['data'] += [Scatter(x=[1,2,3], y=[2,1,2], xaxis='x2', yaxis='y2')]

Not sure about the "alternatively" text - thoughts? @theengineear , @etpinard . I sort of feel like docstring should be as concise and informative and extendable as possible, so we shouldn't have the extra comment and instead do a more thorough job on our hosted docs

Copy link
Contributor

@theengineear theengineear Jan 12, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, let's give one example and link to documentation, we can use that thing to link to the appropriate domain too: https://github.com/plotly/python-api/blob/80fcc59309d59c227a91075070882904e29fb006/plotly/utils.py#L286-292

with the @utils.template_doc wrapper, like in https://github.com/plotly/python-api/blob/a0dad3cc0b70a60e195d4a6ea7eaca06937d1bf3/plotly/plotly/plotly.py#L391

Copy link
Member

besides this comment (#170 (comment)), 💃 from me

Copy link
Contributor

should we make a note about subtle changes (don't have to list them, but just let the user know) here:

https://github.com/plotly/python-api/blob/revamp-get_subplots/plotly/tools.py#L430-433

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /