Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make a python plot interactive

I’m trying to make a plot that I have done in 3D interactive so that I can move it in order to see it from other angles.

cut_k = 0.35
height = 3

#slice at k = 0.08

#Create data for the cylinder
theta = np.linspace(0, 2 * np.pi, 1000)
z_cylinder = np.linspace(0, height, 1000)
theta, z_cylinder = np.meshgrid(theta, z_cylinder)
x_cylinder = cut_k* np.cos(theta)
y_cylinder = cut_k* np.sin(theta)

#plot surface
fig = plt.figure(figsize=(7, 7))
axes = fig.add_subplot(111, projection='3d')
axes.plot_surface(x_cylinder, y_cylinder, z_cylinder, color='red', alpha=1)

This is my code.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I usually use %matplotlib widget to changed the Matplotlib plot to be interactive. However, if you then want to plot a 2d graph you might want to run %matplotlib inline which will kind of reset it. Might not be the most efficient way but it always works for me. I hope this helps.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading