【发布时间】:2020-11-13 14:21:18
【问题描述】:
我正在尝试在图表本身上创建带有文本标签的折线图,但它不起作用。 是 使用您可以在下面看到的文本参数在散点图中工作得非常好。
代码-
import plotly.express as px
fig = px.scatter(crime2,
x='murder',
y='burglary',
size='population',
text='state') # add figure label
fig.update_layout(xaxis_title='Murder Rate',
yaxis_title='Burglary Rate')
fig.update_traces(marker=dict(color='red'))
fig.show()
但它不适用于折线图。 折线图代码 -
fig = px.line(covid_subset,
x='date',
y='total_cases',
color='location',
text='location'
)
fig.update_layout(title='Cumulative Confirmed covid-19 cases')
fig.show()
如您所见,折线图上的国家标签并没有只显示在一个地方,而是一直显示在整个线条上。
我可能遗漏了一些参数,但我不知道它是什么。
这就是我想要做的 -
【问题讨论】:
标签: plotly plotly-python