Skip to content

Commit 8b9ae38

Browse files
committed
addressed review
1 parent 65d0428 commit 8b9ae38

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

doc/python/images.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ It can be useful to add shapes to a layout image, for highlighting an object, dr
313313

314314
In order to enable shape drawing, you need to
315315
- define a dragmode corresponding to a drawing tool (`'drawline'`,`'drawopenpath'`, `'drawclosedpath'`, `'drawcircle'`, or `'drawrect'`)
316-
- add modebar buttons corresponding to the drawing tools you wish to use.
316+
- add [modebar buttons](/python/configuration-options#add-optional-shapedrawing-buttons-to-modebar) corresponding to the drawing tools you wish to use.
317317

318318
The style of new shapes is specified by the `newshape` layout attribute. Shapes can be selected and modified after they have been drawn. More details and examples are given in the [tutorial on shapes](/python/shapes#drawing-shapes-on-cartesian-plots).
319319

@@ -327,7 +327,6 @@ img_width = 1600
327327
img_height = 900
328328
scale_factor = 0.5
329329
fig.add_layout_image(
330-
dict(
331330
x=0,
332331
sizex=img_width,
333332
y=0,
@@ -336,7 +335,7 @@ fig.add_layout_image(
336335
yref="y",
337336
opacity=1.0,
338337
layer="below",
339-
source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/bridge.jpg")
338+
source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/bridge.jpg"
340339
)
341340
fig.update_xaxes(showgrid=False, range=(0, img_width))
342341
fig.update_yaxes(showgrid=False, scaleanchor='x', range=(img_height, 0))

doc/python/shapes.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ fig.show()
720720

721721
_introduced in plotly 4.7_
722722

723-
You can create layout shapes programatically, but you can also draw shapes manually by setting the `dragmode` to one of the shape-drawing modes: `'drawline'`,`'drawopenpath'`, `'drawclosedpath'`, `'drawcircle'`, or `'drawrect'`. If you need to switch between different shape-drawing or other dragmodes (panning, selecting, etc.), modebar buttons can be added in the `config` to select the dragmode. If you switch to a different dragmode such as pan or zoom, you will need to select the drawing tool in the modebar to go back to shape drawing.
723+
You can create layout shapes programatically, but you can also draw shapes manually by setting the `dragmode` to one of the shape-drawing modes: `'drawline'`,`'drawopenpath'`, `'drawclosedpath'`, `'drawcircle'`, or `'drawrect'`. If you need to switch between different shape-drawing or other dragmodes (panning, selecting, etc.), [modebar buttons can be added](/python/configuration-options#add-optional-shapedrawing-buttons-to-modebar) in the `config` to select the dragmode. If you switch to a different dragmode such as pan or zoom, you will need to select the drawing tool in the modebar to go back to shape drawing.
724724

725725
This shape-drawing feature is particularly interesting for annotating graphs, in particular [image traces](/python/imshow) or [layout images](/python/images).
726726

@@ -765,6 +765,8 @@ fig.show(config={'modeBarButtonsToAdd':['drawline',
765765

766766
The layout `newshape` attribute controls the visual appearance of new shapes drawn by the user. `newshape` attributes have the same names as layout shapes.
767767

768+
_Note on shape opacity_: having a new shape's opacity > 0.5 makes it possible to activate a shape by clicking inside the shape (for opacity <= 0.5 you have to click on the border of the shape), but you cannot start a new shape within an existing shape (which is possible for an opacity <= 0.5).
769+
768770
```python
769771
import plotly.graph_objects as go
770772
fig = go.Figure()
@@ -781,7 +783,7 @@ fig.add_annotation(
781783
# shape defined programatically
782784
fig.add_shape(line_color='yellow',
783785
fillcolor='turquoise',
784-
opacity=0.8,
786+
opacity=0.4,
785787
editable=True,
786788
x0=0, x1=1, y0=2, y1=3,
787789
xref='x1', yref='y1'
@@ -790,7 +792,7 @@ fig.update_layout(dragmode='drawrect',
790792
# style of new shapes
791793
newshape=dict(line_color='yellow',
792794
fillcolor='turquoise',
793-
opacity=0.8))
795+
opacity=0.5))
794796
fig.show(config={'modeBarButtonsToAdd':['drawline',
795797
'drawopenpath',
796798
'drawclosedpath',

0 commit comments

Comments
 (0)