plot click on it?

Question:

on this plot i want to remove lines on the graph directly , how is it possible?

import pandas as pd

y = {'sample 135': [12,15,20,15,2,10,6,8], 'sample 2654' : [12,15,20,15,2,5,9,15], 'sample 5454' : [1,2,10,6,8,12,15,20], 'sample 12454' : [15,22,10,6,8,22,25,29], 'sample 54' : [18,20,10,6,8,25,55,9], 'sample 424' : [5,2,10,6,8,4,5,8], 'sample 24545' : [9,12,2,4,55,2,3,7]} 
x = [1,2,3,4,5,6,7,8]

graph = pd.DataFrame(y,x)
graph.plot(kind='line', grid=True, title="outliers dashboard",xlabel=" pixels" , ylabel=" absorbance" )


enter image description here

Asked By: rok

||

Answers:

As plotly library is among the tags, I would use it for more interactive charting. Clicking on variable in the legend will hide/show it.

import pandas as pd
import plotly.express as px

y = {
    "sample 135": [12, 15, 20, 15, 2, 10, 6, 8],
    "sample 2654": [12, 15, 20, 15, 2, 5, 9, 15],
    "sample 5454": [1, 2, 10, 6, 8, 12, 15, 20],
    "sample 12454": [15, 22, 10, 6, 8, 22, 25, 29],
    "sample 54": [18, 20, 10, 6, 8, 25, 55, 9],
    "sample 424": [5, 2, 10, 6, 8, 4, 5, 8],
    "sample 24545": [9, 12, 2, 4, 55, 2, 3, 7],
}
x = [1, 2, 3, 4, 5, 6, 7, 8]
df = pd.DataFrame(y, x).reset_index().melt(id_vars="index")

fig = px.line(df, x="index", y="value", color="variable")
fig.show()
Answered By: BalticCygnus
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.