Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

Adding shape doesn't automatically adjust plot boundaries?

If I run the following:

fig=go.Figure()
fig.add_shape(type="rect",
    x0=10, y0=1, x1=8, y1=3,
    line=dict(color="RoyalBlue"),
)

The plot I get won’t show the rectangle on screen (I have to scroll to see it). When I do something like add_scatter, no matter what I draw, the axes are adjusted to show me all data on screen. Is there anyway to make sure add_shape adjusts axes? Should I be using something other than add shape? Thanks!

@johnc1231
You can get the shape as you expect, by setting axes range:

fig.update_layout(xaxis_range=[a,b], yaxis_range=[c,d])

where [a,b], [c, d] define the plot window where you want to place the shape.

Thanks @empet

The problem with that for me is that if I have something else plotted too, I don’t want to make the ranges smaller and unshow those things. Is there a way to tell a figure to get “at least this big” to make sure the rect is always shown without potentially making the ranges smaller?

@johnc1231

I know you have a trace to plot, but you can set the axes range such that to contain both the shape and one or more traces.