mplot3d

PyPlot legend: 'Poly3DCollection' object has no attribute '_edgecolors2d'

PyPlot legend: 'Poly3DCollection' object has no attribute '_edgecolors2d' Question: The following code snippet works fine until I uncomment the plt.legend() line: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D x = np.linspace(-1, 1) y = np.linspace(-1, 1) X, Y = np.meshgrid(x, y) Z = np.sqrt(X**2 * Y) fig = plt.figure() ax …

Total answers: 5

Plot an energy potential with matplotlib

Plot an energy potential with matplotlib Question: I want to plot the gravitational energy potential to highlight its extremums (the Lagrangian points around two celestial bodies). Here is the function that returns the potential for each set of coordinates x and y: def gravitational_potential(M,m,R,x,y): G = 6.674*10**(-11) omega2 = G*(M+m)/(R**3) r = np.sqrt(x**2+y**2) r2 = …

Total answers: 2

matplotlib 3d axes ticks, labels, and LaTeX

matplotlib 3d axes ticks, labels, and LaTeX Question: 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 = fig.gca(projection=’3d’) theta = np.linspace(-4 * np.pi, 4 * np.pi, 100) z = np.linspace(-2, …

Total answers: 2

Plotting 3D Polygons in Python 3

Plotting 3D Polygons in Python 3 Question: In my quest to somehow get 3D polygons to actually plot, I came across the following script (EDIT: modified slightly): Plotting 3D Polygons in python-matplotlib from mpl_toolkits.mplot3d import Axes3D from matplotlib.collections import Poly3DCollection import matplotlib.pyplot as plt fig = plt.figure() ax = Axes3D(fig) x = [0,1,1,0] y = …

Total answers: 3

mplot3D fill_between extends over axis limits

mplot3D fill_between extends over axis limits Question: I have questions related to creating a simple lineplot in Python with mplot3D where the area under the plot is filled. I am using Python 2.7.5 on RedHatEnterprise 7.2, matplotlib 1.2.0 and numpy 1.7.2. Using the code below, I am able to generate a line plot. This is …

Total answers: 2

Arrows in matplotlib using mplot3d

Arrows in matplotlib using mplot3d Question: I am trying to use matplotlib to recreate the diagram on this page: http://books.google.co.uk/books?id=sf9Qn9MS0ykC&pg=PA18 Here is what I have so far: import numpy as np from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib.patches import FancyArrowPatch from mpl_toolkits.mplot3d import proj3d class Arrow3D(FancyArrowPatch): def __init__(self, xs, ys, …

Total answers: 1

Rotating axes label text in 3D matplotlib

Rotating axes label text in 3D matplotlib Question: How do I rotate the z-label so the text reads (bottom => top) rather than (top => bottom)? import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() ax = fig.add_subplot(111, projection=’3d’) ax.set_zlabel(‘label text flipped’, rotation=90) ax.azim = 225 plt.show() I want this to hold no …

Total answers: 1

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

how to set "camera position" for 3d plots using python/matplotlib? Question: 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 …

Total answers: 5

Setting aspect ratio of 3D plot

Setting aspect ratio of 3D plot Question: I am trying to plot a 3D image of the seafloor from the data of a sonar run over a 500m by 40m portion of the seafloor. I am using matplotlib/mplot3d with Axes3D and I want to be able to change the aspect ratio of the axes so …

Total answers: 5