我在努力做一些我认为应该很直截了当的事情,但我似乎无法让它起作用。
我试着绘制16字节的值,看看它们是如何变化的。我想用散点图来处理: x轴为测量指标 y轴是字节的索引 以及表示字节值的颜色。
我把数据存储在numpy数组中,数据[2][14]会给出第二次测量中的第14个字节的值。
每次我试图策划这个,我都会得到:
ValueError: x and y must be the same size
IndexError: index 10 is out of bounds for axis 0 with size 10
这是我正在使用的样本测试:
import numpy
import numpy.random as nprnd
import matplotlib.pyplot as plt
#generate random measurements
# 10 measurements of 16 byte values
x = numpy.arange(10)
y = numpy.arange(16)
test_data = nprnd.randint(low=0,high=65535, size=(10, 16))
#scatter plot the measurements with
# x - measurement index (0-9 in this case)
# y - byte value index (0-15 in this case)
# c = test_data[x,y]
plt.scatter(x,y,c=test_data[x][y])
plt.show()
我敢肯定我做错了件蠢事,但我好像不知道是什么。
谢谢你的帮助。
尝试使用^{} 来定义点位置,不要忘记正确地索引到NumPy数组(使用
[x,y]
,而不是[x][y]
):相关问题 更多 >
编程相关推荐