3D Wireframe plotting in Python using Matplotlib

To create static, animated and interactive visualizations of data, we use the Matplotlib module in Python. The below programs will depict 3D wireframe. visualization of data in Python. In-order to visualize data using 3D wireframe we require some modules from matplotlib, mpl_toolkits and numpy library.

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing modules
from mpl_toolkits.mplot3d import axes3d
from matplotlib import pyplot 
   
# creating the visualiztion
fig = pyplot.figure()
wf = fig.add_subplot(111, projection='3d')
x, y, z = axes3d.get_test_data(0.05)
wf.plot_wireframe(x,y,z, rstride=2
                  cstride=2,color='green')
   
# displaying the visualization
wf.set_title('Example 1')
pyplot.show()

chevron_right


Output:

In the above program, a 3D wireframe is plotted using test values for coordinates.

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing modules
from mpl_toolkits import mplot3d
import numpy 
from matplotlib import pyplot
  
# assigning coordinates    
a = numpy.linspace(-5, 5, 25)
b = numpy.linspace(-5, 5, 25)
x, y = numpy.meshgrid(a, b)
z = numpy.sin(numpy.sqrt(x**2 + y**2))
  
# creating the visualiztion
fig = pyplot.figure()
wf = pyplot.axes(projection ='3d')
wf.plot_wireframe(x, y, z, color ='green')
  
# displaying the visuliztion
wf.set_title('Example 2')
pyplot.show()

chevron_right


Output:




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.