Proposal for a new example of a polar 3d plot

Attached and also pasted below is an example which creates a 3d figure
using polar coordinates rather than the x and y. The solution was
created by Armin Moser when I posted a question to the users list.
There are currently no examples of polar coordinates in 3D available.

Any objections to adding this to mpl_examples/mplot3d?

Thanks,
Jeff

polar3d_demo.py (605 Bytes)

···

Jeff Klukas, Research Assistant, Physics
University of Wisconsin -- Madison
jeff.klukas@...830... | jeffyklukas@...831... | jeffklukas@...832...
http://www.hep.wisc.edu/~jklukas/

----------------------------------------
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm

fig = plt.figure()
ax = Axes3D(fig)

# create supporting points in polar coordinates
r = np.linspace(0, 1.25, 50)
phi = np.linspace(0, 2*np.pi, 50)
R, PHI = np.meshgrid(r,phi)

# transform them to cartesian system
X,Y = R * np.cos(PHI), R * np.sin(PHI)

Z = ((R**2 - 1)**2)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
ax.set_zlim3d(0, 1)
ax.set_xlabel(r'\\phi\_\\mathrm\{real\}')
ax.set_ylabel(r'\\phi\_\\mathrm\{im\}')
ax.set_zlabel(r'V\(\\phi\)')
ax.set_xticks()
plt.show()
----------------------------------------