Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I draw rectangles on subplots in plotly?

Tags:

python

plotly

How do I draw rectangle (bounding boxes) on a subplot using plotly? I have a graph

fig = plotly.tools.make_subplots(rows=2, cols=1)

and I'd like to add a rectangle to the plot in row 2. For the first row I can do

fig['layout']['shapes'].append(
   {
      'type': 'rect',
      'x0': 1,
      'x1': 2,
      'y0': 3,
      'y1': 4,
      'line': {'color': 'red'}
   }
 )

But I can't figure out how to make a rectangle on the 2nd row.

like image 719
FuriousGeorge Avatar asked Oct 14 '25 15:10

FuriousGeorge


1 Answers

I made a WAG and figured out that you can set

'yref': 'y1'

When creating the shape. Would be nice if there was an example of this on the web page.

like image 120
FuriousGeorge Avatar answered Oct 17 '25 05:10

FuriousGeorge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!