By default, Plotly hides the line on click on its label in the legend section.
Is there a combination of shift/ctrl/alt/
any other keys to make only the selected line appear and hide all the other lines?
Asked
Active
Viewed 1,898 times
2
1 Answers
5
Just double click left mouse button
. If this sounds to easy / good to be true, just try it yourself with this snippet:
Code:
import plotly.express as px
df = px.data.gapminder().query("continent=='Americas'")
fig = px.line(df, x="year", y="lifeExp", color='country')
fig.show()
Plot 1:
Now, if you'd like to look at Haiti only, just hover over the legend, double clik left mouse button
, and this is what you'll get:

vestland
- 55,229
- 37
- 187
- 305
-
While this works, I understand that the question was regarding clicking on the chart itself. Not via the legend. – hard Jan 27 '21 at 19:12
-
nice... Any way to do this programmatically? (E.g. to start with only the first selected...) – ntg Oct 03 '21 at 13:55