You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Shape Layer example not working for layer='between' and yref='y domain' #4645
Hi! Since latest plotly version 5.21 a great addition has been considered by @my-tienpull #6927 being capable of specifying shape layer as 'between' which should solve issues such as presented in plotly/plotly.js#4106.
Example shown in https://plotly.com/python/shapes/ section Shape Layer works fine as it is, but it is not producing expected results when specifying yref='y domain' for the layer='between' subplot. As a mre, the following code:
When yref='y domain' in the case of a simple plot (not a subplot fig), y0 and y1 should take values in [0, 1] for the shapes drawn on the plot rectangle.
Hence y0=0, y1=3 has no sense in your example.
In a simple plot (as in your example) yref='y domain' is equivalent to yref ='paper',
and with adequate y0, y1 it works:
I think that yref='y domain' is not implemented for layer="below", and "between", because these two cases have sense only for yref="y", since only on the plot rectangle there exist gridlines to give the shape position with respect to them. It is even unusual that yref="paper" worked for y0=-0.1 in my example, with layer="below".
fig.add_vrect has as a default parameter value, yref="y domain". That's why it doesn't work because it seems that y domain isn't implemented for the new layers.
Inspecting fig.layout for your last example:
fig.layout
we get the definition for each vrect, but with a different x0, x1, label, and layer, like this one:
Activity
Coding-with-Adam commentedon Jul 1, 2024
hi @archmoj
Does this look like a bug to you?
Codepen.
empet commentedon Jul 2, 2024
When
yref='y domain'in the case of a simple plot (not a subplot fig),y0andy1should take values in [0, 1] for the shapes drawn on the plot rectangle.Hence
y0=0, y1=3has no sense in your example.In a simple plot (as in your example)
yref='y domain'is equivalent toyref ='paper',and with adequate
y0, y1it works:When the fig consists in subplots, yref='yk domain', k=2,... it doesn't work.
subsurfaceiodev commentedon Jul 2, 2024
Using y1 = 1 instead of y1 = 3 for "Between" rectangle as @empet suggested did not solve this issue.
subsurfaceiodev commentedon Jul 2, 2024
This is also affecting functions such as
fig.add_vrectthat call indirectlyfig.add_shape. See following code and resulting incorrect figure:empet commentedon Jul 3, 2024
I think that
yref='y domain'is not implemented forlayer="below", and "between", because these two cases have sense only foryref="y", since only on the plot rectangle there exist gridlines to give the shape position with respect to them. It is even unusual thatyref="paper"worked for y0=-0.1 in my example, with layer="below".subsurfaceiodev commentedon Jul 3, 2024
They DO have sense for this cases, see expected image below:
empet commentedon Jul 3, 2024
fig.add_vrecthas as a default parameter value,yref="y domain". That's why it doesn't work because it seems thaty domainisn't implemented for the new layers.Inspecting
fig.layoutfor your last example:we get the definition for each vrect, but with a different
x0, x1, label, andlayer, like this one:The last three parameters have default values, for this special shape.
Paul-Particle commentedon Jul 10, 2024
It seems to me this is not (only) related to
yref? (this is v5.22.0)