Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Revolution of a curve around the y axis in python

$
0
0

So i have the curve y=1-(x-1)**2 with x being element of [1,2] and i want to plot the surface of revolution of this line around the y axis. Im kinda stuck and didnt much helpful info anywhere.

import numpy as npimport matplotlib.pyplot as pltfig = plt.figure()ax = fig.add_subplot(1, 1, 1, projection='3d')x = np.linspace(1,2,500)y = np.linspace(0,2*np.pi,500)U,V = np.meshgrid(x,y)Y1 = (1-(U-1)**2)*np.cos(V)Z1 = (1-(U-1)**2)*np.sin(V)ax.plot_surface(Y1, U, Z1, alpha=0.3, color='red', rstride=6, cstride=12)ax.view_init(45, 0)ax.set_xlabel('X')ax.set_ylabel('Y')ax.set_zlabel('Z')plt.ylim(-1, 3)plt.show()    

so i dont really know how to make it so it corresponds to whats asked.. sry its my first time asking a question


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>