From 4c2c57cacbd2b7a27ee68ae63eda2ca4c4d47db4 Mon Sep 17 00:00:00 2001 From: Sylwia Mielnicka Date: Tue, 25 Feb 2020 11:05:33 +0100 Subject: [PATCH] Update legend.md Add 'Hide the Trace Implicitly' section. Change 'Size of Legend Items' header from h3 to h4. --- doc/python/legend.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/python/legend.md b/doc/python/legend.md index 9a2996ff178..d11c58305a3 100644 --- a/doc/python/legend.md +++ b/doc/python/legend.md @@ -243,7 +243,30 @@ fig.update_layout( fig.show() ``` -### Size of Legend Items +#### Hide the Trace Implicitly + +`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. + +```python +import plotly.graph_objects as go + +fig = go.Figure() + +fig.add_trace(go.Scatter( + x=[1, 2, 3, 4, 5], + y=[1, 2, 3, 4, 5], +)) + +fig.add_trace(go.Scatter( + x=[1, 2, 3, 4, 5], + y=[5, 4, 3, 2, 1], + visible='legendonly' +)) + +fig.show() +``` + +#### Size of Legend Items 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.