Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4c2c57c

Browse files
Update legend.md
Add 'Hide the Trace Implicitly' section. Change 'Size of Legend Items' header from h3 to h4.
1 parent 5aa8c16 commit 4c2c57c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

doc/python/legend.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,30 @@ fig.update_layout(
243243
fig.show()
244244
```
245245

246-
### Size of Legend Items
246+
#### Hide the Trace Implicitly
247+
248+
`Graph_objects` traces have a `visible` attribute. If set to `legendonly`, the trace is hidden from the graph implicitly. Click on the name in the legend to display the hidden trace.
249+
250+
```python
251+
import plotly.graph_objects as go
252+
253+
fig = go.Figure()
254+
255+
fig.add_trace(go.Scatter(
256+
x=[1, 2, 3, 4, 5],
257+
y=[1, 2, 3, 4, 5],
258+
))
259+
260+
fig.add_trace(go.Scatter(
261+
x=[1, 2, 3, 4, 5],
262+
y=[5, 4, 3, 2, 1],
263+
visible='legendonly'
264+
))
265+
266+
fig.show()
267+
```
268+
269+
#### Size of Legend Items
247270

248271
In this example [itemsizing](https://plot.ly/python/reference/#layout-legend-itemsizing) attribute determines the legend items symbols remain constant, regardless of how tiny/huge the bubbles would be in the graph.
249272

0 commit comments

Comments
 (0)