编辑: 以下来自 Plotly 的示例供参考:
import plotly.express as px
df = px.data.gapminder().query("continent == 'Europe' and year == 2007 and pop > 2.e6")
fig = px.bar(df, y='pop', x='country', text='pop')
fig.update_traces(texttemplate='%{text:.2s}', textposition='outside')
fig.update_layout(uniformtext_minsize=8, uniformtext_mode='hide')
fig.show()
Run Code Online (Sandbox Code Playgroud)
如何删除“流行”一词。
我想隐藏'value'的y轴标题。
fig.update_yaxes(showticklabels=False)
Run Code Online (Sandbox Code Playgroud)
谢谢。
我正在尝试使用plotly为单个图中的多个数据帧绘制折线图。我的代码是:
import plotly.express as px
labels=category_names[:10]
for category in category_names[:10]:
df_b=df1[df1['Country/Region']==category]
fig=px.line(df_b, x="Date", y="Confirmed",labels="Country/Region")
print(category)
fig.show()
Run Code Online (Sandbox Code Playgroud)
但是,通过使用上面的代码,我只能获取 for 循环最后一次迭代的线图。
电流输出:
期望的输出:
请帮助我的代码!