3D plot from multiple arrays
I have successfully plotted a 2d scatter plot:
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()
I want to add a third dimension as hits / interval and worked out this:
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
I can plot each segment of the address successfully to see that it has summed up the total hits for a given interval, but every format I've tried to get a 3D plot to work with hasn't been successful. Hoping that someone knows how I formatted my arrays incorrectly.
3D attempt
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]
results in memory error
try converting to a scatter 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)
This ends, but the timeline is never published and the window must be completed.
+3
source to share
No one has answered this question yet
Check out similar questions: