-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
add_shape, add_layout_image, add_annotation for multiple facets at once #2140
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
|
Once we do the easy version of #2141 then this should apply to |
It looks like the change can just be added by iterating over rows and columns in |
For the specification of multiple rows and columns, I propose the following options
|
Thanks for starting to flesh this out! One thing I'd like to think about is whether we bolt this on to e.g. If we add these new plural methods, then we could consider |
I've also added the possibility of passing the tuple (list,'all') for rows or columns. In this case, all the combinations of rows and columns are used to look up the subplot, even if rows / columns are the same length. |
Finally, |
I've currently implemented in change in the |
Oh I hadn't realized you were already implementing :) Would you mind opening up a draft PR so I can see how you're approaching this? |
Are you tackling #2141 in the same PR or are you starting with this issue and then doing that one? |
Seems some existing related tests to base this off of are in |
No just 2140 for now |
Would it be unreasonable to add this functionality to all the |
Also I'm wondering if there could be a strategy to just test the |
I think there's an important difference between traces and layout objects like annotations, shapes, xaxes etc: the former is "data" and if you want to add more than one you should do so explicitly, whereas the latter is more the frame of the data, and so it makes sense to want to add them in batch. So my gut feeling is that we should not bolt this onto That said, we could probably get some benefit from adding this functionality to |
Re a testing strategy, I would support a layered strategy where we systematically test the inner logic ( |
One nice thing to do in tests is to use https://docs.pytest.org/en/stable/parametrize.html to condense tests a bit. I used this a lot recently in PX tests like https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/tests/test_core/test_px/test_px_wide.py#L48 |
So now that |
Perhaps to please users that mistakenly put 'x domain' say and those that know that in fact you only need 'domain' we just check to see if the xref contains 'domain' (WLOG for yref) and if it does, make the shape reference domain on x+number-determined-by-row-col. |
So with the open PR, can we block this from working with update: I think this |
note: seems |
Do you mean that |
OK after looking into it a bit more, it looks like the problem is when you specify the coordinate for hline or vline that is the same as a 'multicategory' axis, the coordinate seems to default to half of the size of the axis. For example, here specifying a coordinate on a 'category' axis works, but not on 'multicategory' import plotly.graph_objects as go
from plotly import subplots
fig=subplots.make_subplots(1,2)
fig.add_trace(go.Bar(x=['dog','cat','mouse'],y=[5,1,2]),row=1,col=1)
fig.update_xaxes(type='category',row=1,col=1)
fig.add_trace(go.Bar(
x=[["A","A","B","B"],["flower","water","rock","grass"]],
y=[5,1,2,3]
),row=1,col=2)
fig.update_xaxes(row=1,col=2,type='multicategory')
fig.add_vline(x='cat',row=1,col=1)
fig.add_vline(x='mouse',row=1,col=1)
fig.add_vline(x='dog',row=1,col=1)
fig.add_vline(x='water',row=1,col=2)
fig.add_vline(x='rock',row=1,col=2)
fig.add_hline(y=3,row=1,col=2)
fig.show() |
But this bug seems to be from the JS side and it is also in master, so I don't think it's due to this PR (although I could try and fix it). |
So you can't just say |
or maybe either way, so long as this works on numeric/date axes when the opposite axis is multi-cat then I'm happy (the hlines in this case) |
Ah ok nevermind! It works when you do |
Right now if I want to add the same shape (i.e. a horizontal line) to every facet in a PX figure, I have to loop through and do it myself. It seems like having a way of saying
row="*"
or something might be handy.The text was updated successfully, but these errors were encountered: