[英]How to add points or markers to line chart using plotly express?
plotly.express 非常方便制作漂亮的交互图。 下面的代码生成一个按国家/地区着色的折线图。 现在我需要的是给plot加点。有谁知道如何给折线图加点?
import plotly.express as px
gapminder = px.data.gapminder().query("continent=='Oceania'")
fig = px.line(gapminder, x="year", y="lifeExp", color='country')
fig.show()
从 Plotly 版本 5.2.1 开始,这现在可以使用px.line
的markers
参数来实现。 IE
import plotly.express as px
gapminder = px.data.gapminder().query("continent=='Oceania'")
fig = px.line(gapminder, x="year", y="lifeExp", color='country', markers=True)
fig.show()
是否有办法指定标记? 例如,使用 seaborn 我可以将符号列表作为参数传递并为每一行获取特定标记:使用fig = sns.lineplot(data=data, markers=[",", "*", "X", "<", "^", "."])
我会收到这张图片:在此处输入图片描述
谢谢您的回答!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.