I am working on a calculation in Python which calculates the physical properties of an object for angles in the range 0 < θ < π/2 and 0 < φ < π/2 (i.e. the first octant). To visualize the properties I am currently plotting them as color values on a 3D unit sphere. Producing this plot for reasonable resolution is a fairly resource intensive process, but I have no interest in being able to look at the plot from any other angle.
What I would like to create instead is a 2D image plot similar to what imshow
would create except that it should have the triangular outline of a sphere octant being projected into 2D. Note that I am not asking how to project the 3D data into 2D, but rather how to display the 2D data in a manner which looks similar to a sphere octant viewed from θ = π/4, φ = π/4.
My current code is below. The specifics may not be that relevant to an answer, but it gives an idea of what I am trying to do.
'''
The code above this point produces three arrays stored in a dictionary
called phs with the three entries using the keys 'I', 'II', 'III. Each
array is a function of theta and phi where
theta = np.linspace( 0, 90, nPoints)
phi = np.linspace( 0, 90, nPoints)
also
types = ('I', 'II', 'III')
'''
# Colormaps
mx = np.maximum( np.maximum( phs['I'], phs['II']), phs['III'])
cmap = cm.ScalarMappable( cmap='BuPu')
cmap.set_array( mx)
clrs = dict()
for type in types:
clrs[type] = cmap.to_rgba( phs[type])
# Convert to Cartesian coordinates with unit radius
xM, yM, zM = plotCartesianFixedR( thetaM, phiM)
# Plot
fig = plt.figure( figsize=(16,7))
ax = dict()
ax['I'] = plt.subplot( 131, projection='3d')
ax['II'] = plt.subplot( 132, projection='3d')
ax['III'] = plt.subplot( 133, projection='3d')
surf = dict()
for type in types:
surf[type] = ax[type].plot_surface( xM, yM, zM, rstride=1, cstride=1,
facecolors=clrs[type], shade=False)
# Set axis properties
ax[type].set_xticklabels([])
ax[type].set_yticklabels([])
ax[type].set_zticklabels([])
ax[type].view_init(elev=45, azim=45)
# Colorbar
plt.colorbar( cmap, shrink=1)
ax['I'].set_title( 'Log$_{10}(|\Delta k|)$ Type I (ssf)')
ax['II'].set_title( 'Log$_{10}(|\Delta k|)$ Type II (sff)')
ax['III'].set_title( 'Log$_{10}(|\Delta k|)$ Type III (fsf)')
# Add title
if title:
plt.suptitle(title)
The output looks like:
Just to restate the problem; I would like to reproduce this plot almost exactly but in 2D without including the background axes.