[英]How can I plot the figure with the number of pixel as a x-axis and the grayscale color as a y-axis in python?
[英]Dash/Plotly: How can I plot two columns on the y-axis with the same x axis?
我试图在同一个折线图上绘制我的数据集中的两列(列是“病例”和“疫苗接种”)。 x 轴只有一列(即“国家/地区”),我希望他们共享。 是否可以在 Dash/Plotly 中做到这一点? 我找不到任何使用 Dash 的解决方案。 这是我的代码片段:
html.Div(
children=dcc.Graph(
id="cases-chart",
config={"displayModeBar": False},
figure={
"data": [
{
"x": data["country"],
"y": data["cases"],
"type": "lines",
},
],
"layout": {
"title": {
"text": "Cases by Country",
"x": 0.05,
"xanchor": "left",
},
"xaxis": {"fixedrange": True},
"yaxis": {"fixedrange": True},
"colorway": ["#17B897"],
},
},
),
className="card",
),
谢谢。
尝试将另一个元素添加到具有所需数据的“数据”列表中。
您可以在文档中找到更多信息
找到了解决办法:
"data": [
{
"x": data["country"],
"y": data["vaccinations"],
"type": "lines",
},
{
"x": data["country"],
"y": data["cases"],
"type": "lines",
}
],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.