python - 可以使用 Python 在 Plotly 中定义 X 和 Y 值吗?
问题描述
例如,我有以下
情景 1 -
x_names = ['John', 'Jill', 'Sandy']
y_ages = 8,11,10
Trace00 = dict(type = 'bar', x=[x_names], y= [y_ages])
plotly.offline.iplot([Trace00])
结果:由于某种原因,图表未显示任何值
方案 2
Trace00= dict(type= 'bar', x= ['jack', 'jill', 'sandy'], y= [ 8,11,10])
plotly.offline.iplot([Trace00])
结果:成功绘制详细信息。
问题:我可以在轨迹中定义我的 x 值和 y 值吗?无需输入每个对应的值?
解决方案
试试这个,它会工作的。当您将列表列表传递给 x 和 y 时,您将得到失败的输出。
x_names = ['John', 'Jill', 'Sandy']
y_ages = 8,11,10
Trace00 = dict(type = 'bar', x=x_names, y= y_ages)
plotly.offline.iplot([Trace00])
推荐阅读
- sql - SQL Server 制作组
- perl - 如何在 Perl 中 x 秒后创建中断?
- c# - 如何更改 label.text 使用 Task.Run()
- javascript - ie11 上的 sl-vue-tree + vue-cli3.1
- python - 熊猫是否可以自动识别标题是否存在
- python - 对 pandas 中的多个 .csv 文件应用相同的操作
- dart - 在颤振中解析复杂的 JSON 并输入“Future”
' 不是类型 'Future 的子类型 ' - algorithm - 计算给定循环不变量的整数幂
- symfony - 无法在 Symfony 4.1 上安装奏鸣曲/电子商务
- java - 为 ListGrids DataSource 中的错误提供可读的错误消息