Reputation: 1
I want to plot a kind of torus in such a way:
def flux2cart(RHO, PHI, THETA):
XX = (R0 + DEL0*(1.0-RHO**2) + RHO*A0* np.cos(THETA) - RHO*A0*DELTA*np.sin(THETA)**2)*np.cos(PHI)
YY = (R0 + DEL0*(1.0-RHO**2) + RHO*A0* np.cos(THETA) - RHO*A0*DELTA*np.sin(THETA)**2)*np.sin(PHI)
ZZ = (Z0 + KSI0*(1.0-RHO**2) + RHO*A0*LAMBDA*np.sin(THETA) + RHO*A0*GAMMA*np.cos(THETA)**2)
return XX, YY, ZZ
where R0, Z0, A0, DEL0, KSI0, LAMBDA, DELTA
and GAMMA
are constants, PHI
and THETA
are toroidal and poloidal angles and RHO
is a kind of radius, but normalized (0 on axis, 1 on surface).
surface of the torus between 0<φ<2π/3 and two vertical cross-section colored as a function of RHO
:
VAL = (1- RHO**2)**(3/2)
for example.
Plotting surface is easy:
fig, ax = plt.subplots(subplot_kw={"projection": "3d"}, figsize = (12, 10))
rho = 1.
phi = np.linspace(phi0, phi1, 101)
theta = np.linspace(0., 2.*np.pi, 101)
PHI, THETA = np.meshgrid(phi, theta)
XX, YY, ZZ = flux2cart(1., PHI, THETA)
But how to plot contour distribution VAL(RHO, 0., THETA)
and VAL(RHO, 2π/3, THETA)
, where RHO = np.linspace(0., 1., 101)
, on the same figure I have no idea...
I've tried
ax.contourf(np.sqrt(x**2+y**2), z, val, levels=25, cmap=plt.get_cmap('rainbow'))
but that is not (1st picture), what I want (2nd picture)
Upvotes: 0
Views: 19
Reputation: 1
I decided to make something like “stubs” at the ends of the torus, which I depicted as a surface plot:
cmap = plt.cm.ScalarMappable(norm=plt.Normalize(vmin=val.min(), vmax=val.max()), cmap=plt.cm.viridis)
ax.plot_surface(x, y, z, facecolors=cmap.to_rgba(val), shade=False)
Upvotes: 0