简体   繁体   English

如何修改此 plotly 折线图?

[英]How do I modify this plotly line graph?

I am very new to plotly.我对 plotly 很陌生。 Unable to find answers on its documentation.无法在其文档中找到答案。 I created this line chart but i am unable to modify the line chart Example:我创建了这个折线图,但我无法修改折线图示例:

  1. I want two markers on one line我想在一行上有两个标记

  2. renaming axis and legend重命名轴和图例

    data_hum = pd.melt(data,id_vars=['time'],value_vars=['hum_1','hum_2']) fig = px.line(data_hum,x='time',y='value',color='variable')

how to create line chart?如何创建折线图?

I suggest using plotly.graph_objects instead of plotly.express if you want to have more options how to customize your plots.我建议使用 plotly.graph_objects 而不是 plotly.express 如果您想要更多选项来自定义您的绘图。

In your examples this could look something like this在您的示例中,这可能看起来像这样

data_hum = pd.melt(data,id_vars=['time'],value_vars=['hum_1','hum_2'])
fig = go.Figure()
fig.add_trace(go.Scatter(x=data_hum['time'], y=data_hum['hum_1'],
                mode='lines+markers',
                name='Legend label 1'))
fig.add_trace(go.Scatter(x=data_hum['time'], y=data_hum['hum_2'],
                    mode='lines+markers',
                    name='Legend label 2'))

Checkout the official documentation for more information:https://plotly.com/python/line-charts/#line-plot-with-goscatter查看官方文档了解更多信息:https://plotly.com/python/line-charts/#line-plot-with-goscatter

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

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