How to increase the size of an axis (stretch) in a 3D Plot

The code example below provides a way to scale each axis relative to the others. However, to do so you need to modify the Axes3D.get_proj function. Below is an example based on the example provided by matplot lib: http://matplotlib.org/1.4.0/mpl_toolkits/mplot3d/tutorial.html#line-plots (There is a shorter version at the end of this answer) from mpl_toolkits.mplot3d.axes3d import Axes3D from … Read more

Plotting 3D Polygons

I think you’ve almost got it. Is this what you want? from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection import matplotlib.pyplot as plt fig = plt.figure() ax = Axes3D(fig, auto_add_to_figure=False) fig.add_axes(ax) x = [0,1,1,0] y = [0,0,1,1] z = [0,1,0,1] verts = [list(zip(x,y,z))] ax.add_collection3d(Poly3DCollection(verts)) plt.show() You might also be interested in art3d.pathpatch_2d_to_3d.

Annotating a 3D scatter plot

Maybe easier via ax.text(…): from matplotlib import pyplot from mpl_toolkits.mplot3d import Axes3D from numpy.random import rand from pylab import figure m=rand(3,3) # m is an array of (x,y,z) coordinate triplets fig = figure() ax = fig.add_subplot(projection=’3d’) for i in range(len(m)): #plot each point + it’s index as text above ax.scatter(m[i,0],m[i,1],m[i,2],color=”b”) ax.text(m[i,0],m[i,1],m[i,2], ‘%s’ % (str(i)), size=20, … Read more

Plot a 3d pulse propagation

Change to: ax.plot_wireframe(T, z, abs(U), cstride=1000) and call: drawPropagation(1.0, 1.0, numpy.linspace(-2, 2, 10)) will create the following graph: If you need the curve been filled with white color: import numpy from mpl_toolkits.mplot3d import Axes3D from matplotlib import pyplot from matplotlib.collections import PolyCollection def drawPropagation(beta2, C, z): “”” beta2 in ps / km C is chirp … Read more

3D Plots over non-rectangular domain

Abritrary points can be supplied as 1D arrays to matplotlib.Axes3D.plot_trisurf. It doesn’t matter whether they follow a specific structure. Other methods which would depend on the structure of the data would be Interpolate the points on a regular rectangular grid. This can be accomplished using scipy.interpolate.griddata. See example here Reshape the input arrays such that … Read more

Adjust Axes3D label positioning

I share your frustration. I worked on it for a good half hour and got nowhere. The docs say set_xlabel takes an arg labelpad but I get an error (AttributeError: Unknown property labelpad)! Setting it after the fact doesn’t do anything, on xaxis or w_xaxis. Here’s a crude workaround: import matplotlib matplotlib.use(“TKAGG”) import matplotlib.pyplot as … Read more

ValueError: Unknown projection ‘3d’

First off, I think mplot3D worked a bit differently in matplotlib version 0.99 than it does in the current version of matplotlib. Which version are you using? (Try running: python -c ‘import matplotlib; print matplotlib.”__version__”) I’m guessing you’re running version 0.99, in which case you’ll need to either use a slightly different syntax or update … Read more