标签: python plotly plotly-python plotly-express
plotly.express非常便于生成漂亮的交互式图。下面的代码生成按国家/地区着色的折线图。现在,我需要在图上添加点。有人知道我如何在折线图中添加点吗?
import plotly.express as px gapminder = px.data.gapminder().query("continent=='Oceania'") fig = px.line(gapminder, x="year", y="lifeExp", color='country') fig.show()
答案 0 :(得分:1)
使用fig.update_traces(mode='markers+lines')
fig.update_traces(mode='markers+lines')
情节:
代码:
import plotly.express as px gapminder = px.data.gapminder().query("continent=='Oceania'") fig = px.line(gapminder, x="year", y="lifeExp", color='country') fig.update_traces(mode='markers+lines') fig.show()