Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从多个阵列进行三维打印_Python_Arrays_Matplotlib - Fatal编程技术网

Python 从多个阵列进行三维打印

Python 从多个阵列进行三维打印,python,arrays,matplotlib,Python,Arrays,Matplotlib,我正在成功绘制二维散点图: x = np.asarray(plot_data[0])#time variable y = np.asarray(plot_data[1])#address variable fig = plt.figure() ax1 = fig.add_subplot(1,1,1) ax1.scatter(x,y, s=1, c=u'b', edgecolor='None',alpha=.75) ax1.set_xlabel('Time') ax1.set_ylabel('

我正在成功绘制二维散点图:

x = np.asarray(plot_data[0])#time variable
y = np.asarray(plot_data[1])#address variable


fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax1.scatter(x,y, s=1, c=u'b', edgecolor='None',alpha=.75)
ax1.set_xlabel('Time')
ax1.set_ylabel('Address')
ax1.set_title('Memory Accesses')
ax1.plot()
for i in range(60):
    for j in range(0x80000):
        z_array.append(data[i][j])
        x_array.append(i)
        y_array.append(j)

 x = np.asarray(x_array)
 y = np.asarray(y_array)
 z = np.asarray(z_array)

 fig = plt.figure()
 ax = fig.add_subplot(111, projection='3d')
 ax.scatter(x, y, z)
我想添加第三维度作为hits/interval,并开发了以下内容:

time_axis= np.arange(60)
address_axis=np.arange(0x80000)
data = np.zeros((60, 0x80000))

for i in range(len(plot_data[0])):
    if (plot_data[0][i]//interval) == 60:
        i = 59
    data[plot_data[0][i]//interval][plot_data[1][i]]+=1
我可以成功地绘制每个地址片,以查看它已将给定时间间隔内的总点击数相加,但我尝试使3D图形工作的每种格式都不成功。希望有人能了解我是如何错误地格式化数组的

三维尝试

time_axis= np.arange(60)
address_axis=np.arange(0x80000)

fig = plt.figure()
ax = fig.gca(projection='3d')


time_axis, address_axis = np.meshgrid(time_axis, address_axis)
Z = data[time_axis][address_axis]
导致内存错误

尝试转换为散点图:

x = np.asarray(plot_data[0])#time variable
y = np.asarray(plot_data[1])#address variable


fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax1.scatter(x,y, s=1, c=u'b', edgecolor='None',alpha=.75)
ax1.set_xlabel('Time')
ax1.set_ylabel('Address')
ax1.set_title('Memory Accesses')
ax1.plot()
for i in range(60):
    for j in range(0x80000):
        z_array.append(data[i][j])
        x_array.append(i)
        y_array.append(j)

 x = np.asarray(x_array)
 y = np.asarray(y_array)
 z = np.asarray(z_array)

 fig = plt.figure()
 ax = fig.add_subplot(111, projection='3d')
 ax.scatter(x, y, z)

此操作完成,但图形从未发布,窗口必须终止。

查看此操作的任何人:都在过度思考问题。手动将阵列转换为存储单元,然后与曲面打印示例类似地打印这些存储单元。基本上,解决方案是
x=range(bin\u size)y=range(bin\u size)x,y=np.meshgrid(x,y)ha.plot\u surface(x,y,data,alpha=.7,cmap=mpl.cm.coolwarm)print(np.amax(data))