How to Toggle Graphs Visibility By Clicking Legend Label in Matplotlib

preview_player
Показать описание
In this #Matplotlib tutorial, I will go over the steps how to use Matplotlib legend to toggle charts' visibility in Python.

01:57 Create x and y data points
03:26 Plot the graphs
04:53 Configure Legend object
06:62 Handle Matplotlib events

Buy Me a Coffee? Your support is much appreciated!
----------------------------------------------------------------------------------------------------------------
Venmo: @Jie-Jenn

Supporting my channel so I can continue making free contents
----------------------------------------------------------------------------------------------------------------
Рекомендации по теме
Комментарии
Автор

Hi, I used the exact same code provided by you. If I click an the table to deselect the line it is not working though (the graph shows). How is that possible

margote
Автор

Is it supposed to work with Jupyter Notebook? Unfortunately I only find it working with IDE, but great solution anyway

sowki_tv
Автор

Thanks a lot! Is it possible to make the text "line" and "dot" clickable?

thenarfer
Автор

Is it possible for the graph to autoscale based on the series that are displayed. For example, I have a csv file that contains multiple series, so I'd like to use one column for the x-axis, and want the user to select one or more columns for the y-axis. I was thinking it would default showing all the data/columns, with checkboxes for each series that that the user can then un/select to hide/show that data and the plot would scale according to whats selected.

Do you think gnuplot could do this easily, or would another tool be easier? matplotlib, plotly, C3js ? I've seen others (SO 31410043, 28463479 14629438 or GH Bokeh issue 3715) also looking for this functionality.

bennguyen
Автор

Hey I have a question
If I click on the graph that particular coordinates of graph has to be stored in a variable how can I do that.

sriharivaila