Like this: import matplotlib.pyplot as plt # Reference or starting point to create vectors start = [0, 0, 0] # Ending points of vectors u = [7, 3, 1] v = [1, 5, 4] q = [3, -8, 4] fig = plt.figure() ax = plt.axes(projection = '3d') # Define axis limits ax.set_xlim([-1, 10]) ax.set_ylim([-10, 10]… Answer from onePythonUser on discuss.python.org
🌐
PyVista
pyvista.org
PyVista | 3D plotting & analysis made easy
PyVista is a Python library for 3D visualization and mesh analysis that works naturally with NumPy, pandas, xarray, and the rest of the scientific Python ecosystem.
🌐
Reddit
reddit.com › r/python › seeking library recommendation for 3d visualization of crystal structure
r/Python on Reddit: Seeking library recommendation for 3D visualization of crystal structure
November 6, 2022 -

Hi, I'm a material scientist and part of my work includes creating crystal structures. I'm looking two write a python script that can visualize the crystal structures I create. So the crystal structure file looks something like this

#line number     atom type    X-cordinate    Y-cordinate    Z-cordinate    
1                     A              0.0            0.0          0.0      
2                     A              1.0            0.0          0.0      
3                     B              0.0            1.0          0.0      
4                     B              0.0            0.0          1.0     
...                   ...             ...            ...          ...      
100                   B               100.0           0.0          0.0 

I'm looking for a python library to visualize these structures in 3D and in an interactive way. The atoms should be represented with spheres of different colors based on their type. Is there a Python library which lets us do this in an easy way?

Discussions

Interactive animated 3D visualization of movement and orientation data?
I am working on object orientation and movement tracking and I need a way to visualize that data. For this I would like to graph the 3-axes arrows of the object frame in some kind of interactive 3D plot that would represent the world frame. Ideally, that visualization would be: interactive: ... More on discuss.python.org
🌐 discuss.python.org
7
0
June 19, 2024
python - Make 3D plot interactive in Jupyter Notebook - Stack Overflow
For 3-D visualization pythreejs is the best way to go probably in the notebook. It leverages the interactive widget infrastructure of the notebook, so connection between the JS and python is seamless. A more advanced library is bqplot which is a d3-based interactive viz library for the iPython notebook, but it only does 2D ... Save this answer. ... Show activity on this post. plotly's px.scatter_3d ... More on stackoverflow.com
🌐 stackoverflow.com
python 3D visualization and graphics - Stack Overflow
I am looking for Python compatible 3D graphics. Mostly I would like to be able to draw lines and view them in 3D. I literally have no experience in this area and am looking for knowledge and tutori... More on stackoverflow.com
🌐 stackoverflow.com
Seeking library recommendation for 3D visualization of crystal structure
Easiest to get up and running might be mayavi . It's not perfect, but it is 3D and reasonably interactive (unlike matplotlib's 3D plots, for example). More on reddit.com
🌐 r/Python
34
81
November 6, 2022
🌐
Epsilonforge
epsilonforge.com › post › best-3d-scientific-visualization
Best Scientific 3D Visualization Libraries for Python
The PyVista developers also support ... of the surface mesh resampling algorithm ACVD. ... Also based on VTK, MayaVi is a Python library for 3D visualization....
🌐
GitHub
github.com › pyvista › pyvista
GitHub - pyvista/pyvista: 3D visualization and mesh analysis for science and engineering · GitHub
PyVista is used across science and engineering disciplines to visualize 3D data and models, generate publication-quality figures, automate analysis workflows, and build custom applications on top of PyVista's 3D capabilities.
Author: pyvista
🌐
Plotly
plotly.com › python › 3d-charts
3d charts in Python
Plotly's Python graphing library makes interactive, publication-quality graphs online. Examples of how to make 3D charts.
Find elsewhere
🌐
Open3D
open3d.org
Open3D – A Modern Library for 3D Data Processing
3D visualization with Physically based rendering (PBR) 3D machine learning support with PyTorch and TensorFlow · GPU acceleration for core 3D operations · Available in C++ and Python with a 3D viewer app. GCC 5.X and later on Linux · XCode 10+ and later on OS X 10.14+ Visual Studio 2019 and later on Windows ·
🌐
MeshLib
meshlib.io › home › blog › top 5 python libraries for 3d geometry
The Best Python 3D Geometry Libraries for Mesh, Reconstruction, and Visualization in 2025
August 20, 2025 - Informative overview of key capabilities offered by modern Python 3D Geometry Libraries for modern 3D data processing practices, including MeshLib, PyMesh, Opend3D, libigl, and VTK.
🌐
GeeksforGeeks
geeksforgeeks.org › python › three-dimensional-plotting-in-python-using-matplotlib
Three-dimensional Plotting in Python using Matplotlib - GeeksforGeeks
Visualizing data involving three ... Python’s Matplotlib library, through its mpl_toolkits.mplot3d toolkit, provides powerful support for 3D visualizations....
Published: July 15, 2025
🌐
Matplotlib
matplotlib.org › stable › gallery › mplot3d › index.html
3D plotting — Matplotlib 3.11.2 documentation
Skip to main content · Back to top · Plot types · User guide · Tutorials · Examples · Reference · Contribute · Releases · Choose version
🌐
Python.org
discuss.python.org › python help
Interactive animated 3D visualization of movement and orientation data? - Python Help - Discussions on Python.org
June 19, 2024 - I am working on object orientation and movement tracking and I need a way to visualize that data. For this I would like to graph the 3-axes arrows of the object frame in some kind of interactive 3D plot that would repres…
🌐
Plotly
dash.plotly.com › vtk › intro
Intro to 3D Visualization | Dash for Python Documentation | Plotly
A representation is responsible for converting a DataSource into something visual that will be available inside the View. So far we are exposing to dash_vtk 3 core types of Representation: - GeometryRepresentation: The geometry representation will expect a mesh and will render it as geometry rendering (think triangle sets). - VolumeRepresentation: The volume representation will expect a 3D image and will render it using a Volume Rendering technique that will let you see through (foggy object).
🌐
S3dlib
s3dlib.org
Introduction — S3Dlib - 3D Visualization with Python
S3Dlib is a Python library for visualizing 3D surfaces and lines which is used in conjunction with the Matplotlib library.
🌐
Towards Data Science
towardsdatascience.com › home › latest › python libraries for mesh, point cloud, and data visualization (part 1)
Python Libraries for Mesh, Point Cloud, and Data Visualization (Part 1) | Towards Data Science
April 26, 2022 - This is Part 1 of the planned tutorials on Python libraries for 3D work and visualization. In this part, we present the first 4 libraries for visualization - Open3D, Trimesh, PyVista, and Vedo, while Part 2 will focus on Pyrender, PlotOptiX, ...
Top answer
1 of 7
130

try:

%matplotlib notebook

see jakevdp reply here

EDIT for JupyterLab users:

Follow the instructions to install jupyter-matplotlib

Then the magic command above is no longer needed, as in the example:

# Enabling the `widget` backend.
# This requires jupyter-matplotlib a.k.a. ipympl.
# ipympl can be install via pip or conda.
%matplotlib widget
# aka import ipympl

import matplotlib.pyplot as plt

plt.plot([0, 1, 2, 2])
plt.show()

Finally, note Maarten Breddels' reply; IMHO ipyvolume is indeed very impressive (and useful!).

2 of 7
36

You may go with Plotly library. It can render interactive 3D plots directly in Jupyter Notebooks.

To do so you first need to install Plotly by running:

pip install plotly

You might also want to upgrade the library by running:

pip install plotly --upgrade

After that in you Jupyter Notebook you may write something like:

# Import dependencies
import plotly
import plotly.graph_objs as go

# Configure Plotly to be rendered inline in the notebook.
plotly.offline.init_notebook_mode()

# Configure the trace.
trace = go.Scatter3d(
    x=[1, 2, 3],  # <-- Put your data instead
    y=[4, 5, 6],  # <-- Put your data instead
    z=[7, 8, 9],  # <-- Put your data instead
    mode='markers',
    marker={
        'size': 10,
        'opacity': 0.8,
    }
)

# Configure the layout.
layout = go.Layout(
    margin={'l': 0, 'r': 0, 'b': 0, 't': 0}
)

data = [trace]

plot_figure = go.Figure(data=data, layout=layout)

# Render the plot.
plotly.offline.iplot(plot_figure)

As a result the following chart will be plotted for you in Jupyter Notebook and you'll be able to interact with it. Of course you will need to provide your specific data instead of suggeseted one.

🌐
Medium
medium.com › @jianxiawzx123 › mastering-3d-data-visualization-in-python-from-surface-plots-to-triangular-meshes-92c158ca1806
Mastering 3D Data Visualization in Python: From Surface Plots to Triangular Meshes | by DebugTheWorld | Medium
June 11, 2025 - Data visualization involving three ... two-dimensional representations. Python’s Matplotlib library, leveraging its mpl_toolkits.mplot3d toolkit, offers robust capabilities for generating sophisticated 3D visualizations....
🌐
Matplotlib
matplotlib.org › stable › gallery › mplot3d › scatter3d.html
3D scatterplot — Matplotlib 3.11.2 documentation
""" return (vmax - vmin)*np.random.rand(n) + vmin fig = plt.figure() ax = fig.add_subplot(projection='3d') n = 100 # For each set of style and range settings, plot n random points in the box # defined by x in [23, 32], y in [0, 100], z in [zlow, zhigh]. for m, zlow, zhigh in [('o', -50, -25), ('^', -30, -5)]: xs = randrange(n, 23, 32) ys = randrange(n, 0, 100) zs = randrange(n, zlow, zhigh) ax.scatter(xs, ys, zs, marker=m) ax.set_xlabel('X Label') ax.set_ylabel('Y Label') ax.set_zlabel('Z Label') plt.show()
Author: duchaba
🌐
Cdslab
cdslab.org › python › notes › visualization › 3d › 3d.html
3D-plotting | Data Science with Python
This note attempts to provide a summary of the myriad of the existing methods of 3D data visualization in Python.
Top answer
1 of 2
33

The easiest way for 3D visualization in Python is VPython.

For example, to draw a curve in the shape of a square, it's just:

square = curve(pos=[(0,0),(0,1),(1,1),(1,0),(0,0)])

This is vastly easier than MayaVI, VTK, OpenGL, etc.

Another easy option is matplotlib's 3D graphics. It's better on the quantitative details, but not as simple, fast, and interactive for the 3D part.

2 of 2
22

For 3D charts and graphs (Edit)

If you just need to draw a 3D graph and periodically update it, gnuplot may be appropriate. Using Python's subprocess library you can spawn it in a process to produce graphs, with a variety of output formats, such as SVG or PNG.

Also see Tom's answer below for an alternative library recommendation.

For Realtime 3D (Original)

This answer is for those who are interested in realtime graphics.

The standard way to render 3D graphics is with the OpenGL library which interfaces with the GPU. OpenGL is a big topic, but focusing on a specific application, like drawing 3D lines should not be too difficult.

Bindings exist for python http://pyopengl.sourceforge.net/

GLUT - is probably the best for providing X platform windowing and context setup, and is included in the mentioned bindings.

OpenGL - there are two main ways to use Opengl, a "legacy" style, and a "modern" one. For simple applications legacy is often easier to get started, although learning modern is a better long-term investment.

Here are some links for learning - Don't feel obligated to read them all - pick the topics that are relevant to you.

  • http://greendalecs.wordpress.com/2012/04/21/3d-programming-in-python-part-1/
  • http://www.informit.com/articles/article.aspx?p=328646&seqNum=6
  • http://www.videotutorialsrock.com/
  • http://nehe.gamedev.net/ (legacy)
🌐
DataCamp
datacamp.com › tutorial › matplotlib-3d-volumetric-data
Python Matplotlib 3D Visualization with Volumetric Data | DataCamp
April 19, 2017 - When working with images in Python, the most common way to display them is using the imshow function of Matplotlib, Python’s most popular plotting library. In this tutorial, we’ll show you how to extend this function to display 3D volumetric data, which you can think of as a stack of images.