Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotly: How to show only the clicked line?

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?

like image 754
imdevskp Avatar asked Oct 14 '25 03:10

imdevskp


1 Answers

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:

enter image description here

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:

enter image description here

like image 152
vestland Avatar answered Oct 16 '25 17:10

vestland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!