【发布时间】:2022-01-17 23:01:56
【问题描述】:
我有以下清单:
[1, 2, 3, 17, 16, 4, 7, 6, 13, 12, 5, 24]
这些都有相关的值:
[6.254484668288452e-08,
0.48735364325982383,
2.691646548287535e-07,
4.746326705218297e-15,
4.889505772899467e-19, ...]
我希望使用plt.scatter 绘制这些值
但是,在绘制 xscale [1,2,3,17,16 等...] 时,显然设置为有序,因此失去了我试图广播的特定含义。我希望在绘图时保持这个顺序有没有办法做到这一点?
我是这样设计的,但它并没有按照我的意愿进行。
plt.scatter(lst1, lst2, s=50)
plt.xticks(lst1)
y=[0.05 for a in range(24)] # necessary for me to show significance
plt.plot(x,y,"r+")
plt.show()
【问题讨论】:
-
也许是
plt.scatter(map(str, lst1), lst2)?如果没有,您的预期输出是什么? -
应该是
plt.scatter(list(map(str, lst1)), lst2)否则我会收到一条错误消息“matplotlib 不支持生成器作为输入” -
@not_speshal 谢谢!这已经奏效了。
标签: python python-3.x matplotlib