Question

I've been plotting four dimensional data for my thesis using a colormap on a 3D graph and encountered a complication. It would appear that the colormap method I am using averages the values at the corner points and then colors the entire tile by that value. This would be fine if I had a bigger resolution, but it's taken me about a month to run the simulations to get my current data.

Can anybody suggest a way to change this? Preferably not by coding my own linear interpolation of all the points to increase the resolution. That's probably more effort (for me) than it's worth at this point.

Driven=np.zeros((5,9))
Driver=np.zeros((5,9))
Compositions=np.zeros((5,9))
Durations=np.zeros((5,9))
N=np.zeros((5,9))
for i in range(0,5):
    for j in range(0,9):
        Driven[i,j]=ReservoirData[i][1][j]
        Compositions[i,j]=ReservoirData[i][2][j]
        Driver[i,j]=float(ReservoirData[i][0][0][:-3])
        Durations[i,j]=ReservoirData[i][3][j]
maxi=Durations.max()
mini=Durations.min()
for i in range(0,5):
    for j in range(0,9):
        N[i,j]=(Durations[i,j]-mini)/(maxi-mini)

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

#Important Stuff    Start----------------------------------------------------

surf = ax.plot_surface(Driven,Driver,Compositions, facecolors=cm.jet(N), rstride=1, cstride=1, antialiased=True)
m = cm.ScalarMappable(cmap=cm.jet)

#Important Stuff End---------------------------------------------------------

m.set_array(Durations)
cbar=plt.colorbar(m, shrink=0.8)
cbar.set_label('Nominal Duration')
ax.set_ylabel('Driver Pressure, kPa')
ax.set_xlabel('Compositions, %He')
ax.set_zlabel('Driven Pressure, kPa')
plt.title('Three Dimensional Representation of Tailored Conditions for RS at 9.2MPa')
fig.set_size_inches(14,8)
plt.savefig('RS9.2.png')

enter image description here Any opinions are welcome, thanks!

Was it helpful?

Solution

To my experience, matplotlib is, lets say, not ideal for doing 3D plots. Because of issues like this, I switched to mayavi (link) for this purpose; it might already help you out (and it looks beautiful!). If need be, there are handy interpolation tools in scipy.interpolate, to "increase" your data density, check them out here.

I always mark real measurement data on the interpolation surface (only 2D, though) for clarity; this might be feasible for you as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top