简体   繁体   中英

How do I draw rectangles on subplots in 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM