简体   繁体   English

如何通过单击删除 plot 上的特定行?

[英]how i can remove a specific line on my plot with a click on it?

on this plot i want to remove lines on the graph directly, how is it possible?在这个 plot 我想直接删除图表上的线条,这怎么可能?

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" )


在此处输入图像描述

As plotly library is among the tags, I would use it for more interactive charting.由于 plotly 库是其中的标签,我会使用它来进行更多交互式图表。 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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM