我试着画两个数组/列表的散点图,其中一个是x坐标,另一个是y坐标,我没有任何问题。但是,我需要根据这些点在特定时间点的值,基于我在二维数组中的数据,对这些点进行颜色编码。此外,这个二维数据数组有一个非常大的分布,所以我想对数着色这些点(我不确定这是否意味着只改变颜色条标签,或者是否有更根本的区别)。
到目前为止,我的代码如下:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(1)
time = #I'd like to specify time here.
x = [1, 2, 3, 4, 5]
y = [5, 4, 3, 2, 1]
multi_array = [[1, 1, 10, 100, 1000], [10000, 1000, 100, 10, 1], [300, 400, 5000, 12, 47]]
for counter in np.arange(0, 5):
t = multi_array[time, counter] #I tried this, and it did not work.
s = plt.scatter(x[counter], y[counter], c = t, marker = 's')
plt.show()我遵循了我在其他地方看到的建议,通过第三个变量进行着色,即将颜色设置为等于该变量,但是当我尝试使用我的数据集时,我只获得了所有的点作为一种颜色,然后当我尝试使用此模型时,它给出了以下错误:
TypeError: list indices must be integers, not tuple有没有人能帮我按我需要的方式给我的点上色?
https://stackoverflow.com/questions/38148362
复制相似问题