2024-09-30 20:25:14 发布
网友
我有一张看起来像这样的桌子。。。在
ticker,price1y,price2y,price3y,price5y, aapl,12,23,47,69, tsla,-9,24,54,190, att,-10,23,34,35,
我想用熊猫在破折号中描绘这些故事,以显示昂贵的价格。。。沿x轴的价格为5y,y轴上的百分比为。我需要能够使用dash的回调功能选择多个值添加到图表中。在
我目前创建了一个仪表板核心组件图,但我一直未能成功地绘制到这一点。在
谢谢
您可以使用绘图中的grouped bar chart:
导入:
import plotly.plotly as py import plotly.graph_objs as go
示例数据帧:
看起来像:
price1y price2y price3y price5y ticker aapl 12 23 47 69 tsla -9 24 54 190 att -10 23 34 35
然后,迭代列并为分组条形图动态创建数据:
res = [] for col in df.columns: res.append( go.Bar( x=df.index.values.tolist(), y=df[col].values.tolist(), name=col ) ) layout = go.Layout( barmode='group' ) fig = go.Figure(data=res, layout=layout) py.iplot(fig, filename='grouped-bar')
这将产生:
为了在Dash中得到它,您需要从回调中返回上面的值。在
您可以使用绘图中的grouped bar chart:
导入:
示例数据帧:
^{pr2}$看起来像:
然后,迭代列并为分组条形图动态创建数据:
这将产生:
为了在Dash中得到它,您需要从回调中返回上面的值。在
相关问题 更多 >
编程相关推荐