Plotting circles on different planes

-2

I need to plot circles in the zy and zx planes, but I can only plot in the xy plane, because by changing the variables x, y and z, I forget the shape of the circle. How can I fix this?

import numpy as np
from matplotlib import pyplot as plt
import mpl_toolkits.mplot3d.axes3d

theta = np.linspace(0, 2.*np.pi, 100)
phi = np.linspace(0, 2*np.pi, 100)
theta, phi = np.meshgrid(theta, phi)
c, a = 1, 0.05
x = (c + a*np.cos(theta)) * np.cos(phi)
y = (c + a*np.cos(theta)) * np.sin(phi)
z = a * np.sin(theta)

fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')
ax1.set_zlim(-10,10)
ax1.plot_surface(x, y, z, color='b', edgecolors='b')
ax1.view_init(36, 26)

plt.show()
    
asked by anonymous 04.10.2018 / 01:57

1 answer

0

You must zero the coordinate of the axis that you do not want the circle to appear. For example, if you want to plot the circle in the zy plane, then

ax1.plot_surface(xzero, y, z, color='b', edgecolors='b')

where xzero is a vector of zeros ([0,0,0, ..]) with the same dimension of y and z.

The same thing you do for the other plans.

    
04.10.2018 / 03:06