python画二维数组散点图_Python散点图二维数组
我在努力做一些我認為應該很直截了當的事情,但我似乎無法讓它起作用。
我試著繪制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()
我敢肯定我做錯了件蠢事,但我好像不知道是什么。
謝謝你的幫助。
總結
以上是生活随笔為你收集整理的python画二维数组散点图_Python散点图二维数组的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 修改 class_带你探索JVM的Cla
- 下一篇: python fromfile_pyth