Questions tagged [matplotlib-3d]

For questions about 3d plotting with matplotlib. Also use the matplotlib tag.

matplotlib: 3D plotting

335 questions
187
votes
5 answers

how to set "camera position" for 3d plots using python/matplotlib?

I'm learning how to use mplot3d to produce nice plots of 3d data and I'm pretty happy so far. What I am trying to do at the moment is a little animation of a rotating surface. For that purpose, I need to set a camera position for the 3D projection.…
Andreas Bleuler
  • 1,991
  • 2
  • 12
  • 6
139
votes
6 answers

ValueError: Unknown projection '3d'

I just installed matplotlib and am trying to run one of there example scripts. However I run into the error detailed below. What am I doing wrong? from mpl_toolkits.mplot3d import axes3d import matplotlib.pyplot as plt fig = plt.figure() ax =…
rectangletangle
  • 50,393
  • 94
  • 205
  • 275
133
votes
4 answers

How to make a 3D scatter plot

I am currently have a nx3 matrix array. I want plot the three columns as three axis's. How can I do that? I have googled and people suggested using Matlab, but I am really having a hard time with understanding it. I also need it be a scatter plot.
user211037
  • 1,725
  • 5
  • 16
  • 11
121
votes
7 answers

Make 3D plot interactive in Jupyter Notebook

I use Jupyter Notebook to make analysis of datasets. There are a lot of plots in the notebook, and some of them are 3d plots. I'm wondering if it is possible to make the 3d plot interactive, so I can later play with it in more details? Maybe we can…
ZK Zhao
  • 19,885
  • 47
  • 132
  • 206
111
votes
10 answers

How to set the 'equal' aspect ratio for all axes (x, y, z)

When I set up an equal aspect ratio for a 3d graph, the z-axis does not change to 'equal'. So this: fig = pylab.figure() mesFig = fig.gca(projection='3d', adjustable='box') mesFig.axis('equal') mesFig.plot(xC, yC, zC, 'r.') mesFig.plot(xO, yO, zO,…
user1329187
97
votes
3 answers

Plotting a 3d cube, a sphere and a vector

I search how to plot something with less instruction as possible with Matplotlib but I don't find any help for this in the documentation. I want to plot the following things: a wireframe cube centered in 0 with a side length of 2 a "wireframe"…
Vincent
  • 57,703
  • 61
  • 205
  • 388
84
votes
2 answers

How to hide axes and gridlines

I would like to be able to hide the axes and gridlines on a 3D matplotlib graph. I want to do this because when zooming in and out the image gets pretty nasty. I'm not sure what code to include here but this is what I use to create the graph. fig =…
Alex Santelle
  • 935
  • 2
  • 8
  • 9
83
votes
6 answers

Displaying rotatable 3D plots in IPython or Jupyter Notebook

(Mac OSX 10.10.5) I can reproduce from the matplotlib website mplot3d the example code for a 3D scatter plot scatter3d_demo.py, however the plot renders as a static image. I can not click on the graph and dynamically rotate to view the 3D plotted…
Cam_Aust
  • 2,529
  • 2
  • 19
  • 28
75
votes
12 answers

set matplotlib 3d plot aspect ratio

import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D Setting the aspect ratio works for 2d plots: ax = plt.axes() ax.plot([0,1], [0,10]) ax.set_aspect('equal', 'box') But it does not work for 3d: ax =…
hatmatrix
  • 42,883
  • 45
  • 137
  • 231
72
votes
1 answer

Plotting 3D Polygons

I was unsuccessful browsing web for a solution for the following simple question: How to draw 3D polygon (say a filled rectangle or triangle) using vertices values? I have tried many ideas but all failed, see: from mpl_toolkits.mplot3d import…
Developer
  • 8,258
  • 8
  • 49
  • 58
69
votes
7 answers

Annotating a 3D scatter plot

I'm trying to generate a 3D scatter plot using Matplotlib. I would like to annotate individual points like the 2D case here: How to put individual tags for a matplotlib scatter plot?. I've tried to use this function and consulted the Matplotlib…
Yang
  • 7,712
  • 9
  • 48
  • 65
56
votes
3 answers

How to display a 3D plot of a 3D array isosurface with mplot3D or similar

I have a 3-dimensional numpy array. I'd like to display (in matplotlib) a nice 3D plot of an isosurface of this array (or more strictly, display an isosurface of the 3D scalar field defined by interpolating between the sample points). matplotlib's…
timday
  • 24,582
  • 12
  • 83
  • 135
54
votes
2 answers

3d axes ticks, labels, and LaTeX

I am running this sample script, with the following modifications: import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D import numpy as np import matplotlib.pyplot as plt mpl.rcParams['legend.fontsize'] = 10 fig = plt.figure() ax =…
Forklift17
  • 2,245
  • 3
  • 20
  • 32
49
votes
3 answers

Putting arrowheads on vectors in a 3d plot

I plotted the eigenvectors of some 3D-data and was wondering if there is currently (already) a way to put arrowheads on the lines? Would be awesome if someone has a tip for me. import numpy as np from matplotlib import pyplot as plt from…
user2489252
47
votes
1 answer

ValueError: Unknown projection '3d' (once again)

When executing this line of code: import matplotlib.pyplot as plt #your code fig = plt.figure() ax = fig.gca(projection='3d') I have an output error: raise ValueError("Unknown projection %r" % projection) ValueError: Unknown projection…
Leos313
  • 5,152
  • 6
  • 40
  • 69
1
2 3
22 23