mplot3d

mplot3d: Hiding a line plot `plot()` under a `plot_surface()`

强颜欢笑 提交于 2020-01-04 05:50:12
问题 Edit: the problem I describe here no longer shows with current versions of matplotlib (2.1.1, edit made on 10 Sep 2019): most certainly a bug that has been fixed since then I want to have a line plot (drawn with Axis.plot() ) that is partially covered by the surface generated by Axis.plot_surface() . I wrote the following script: import numpy as np from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D resolution = 100 ax = plt.gca(projection="3d") x, y = np.meshgrid( np

How to visualize 3D delaunay triangulation in Python?

假装没事ソ 提交于 2020-01-02 05:45:32
问题 I have a set of 3D points which I've used scipy.spatial.Delaunay to do the triangulation / tetrahedralization. I now have a set of unique faces of all of the tetrahedra, and would like to visualize these in 3D. Are there any Python libraries (or libraries with a Python wrapper) that can do this? 回答1: Try mayavi.mlab.triangular_mesh() import numpy as np from mayavi import mlab vertices = np.array([[0, 1, 0, 0],[0, 0, 1, 0],[0, 0, 0, 1]]) faces = np.array([[0, 1, 0, 0],[1, 2, 1, 2],[2, 3, 3, 3]

Connecting two points in a 3D scatter plot in Python and matplotlib

荒凉一梦 提交于 2020-01-01 01:56:10
问题 In the code below, how do I create lines connecting each pair of scatter plots (i.e. linking the green circle to the yellow arrowhead) created by the two lines of code towards the end just before the .show() instruction? import matplotlib.pyplot from mpl_toolkits.mplot3d import Axes3D dates = [20020514, 20020515, 20020516, 20020517, 20020520] highs = [1135, 1158, 1152, 1158, 1163] lows = [1257, 1253, 1259, 1264, 1252] upperLimits = [1125.0, 1125.0, 1093.75, 1125.0, 1125.0] lowerLimits = [1250

Setting tick colors of matplotlib 3D plot

大憨熊 提交于 2019-12-31 00:05:06
问题 If I have a 3D matplotlib plot ( Axes3D object), how do I change the color of the tick marks? I figured out how to change the color of the axis line, the tick labels, and the axis label. The obvious solution, use ax.tick_params(axis='x', colors='red') , only changes the tick labels not the tick marks themselves. Here is code that tries to change all the axes to red and gets everything but the tick marks: from mpl_toolkits.mplot3d import Axes3D from matplotlib import pyplot as plt fig = plt

Trying to add a 3d subplot to a matplotlib figure

不想你离开。 提交于 2019-12-30 09:54:09
问题 So I'm trying to create a figure that presents a 3d plot from data points, along with the plots 3 projections in 3 other subplots. I can add the subplots for the projections with no problems, but when I try to place the 3 dimensional plot into the figure things backfire. here's my code: def plotAll(data): fig = plt.figure() plot_3d = fig.add_subplot(221) ax = Axes3D(plot_3d) for i,traj in enumerate(data.values()): ax.plot3D([traj[0][-1]],[traj[1][-1]],[traj[2][-1]],".",color=[0.91,0.39,0.046]

Plot 3D convex closed regions in matplot lib

徘徊边缘 提交于 2019-12-28 12:33:29
问题 I am trying to plot in 3D a polytope defined by a set of inequalities. Essentially, I try to reproduce the functionality of this matlab plotregion library in matplotlib. My approach is to get the intersection vertices, construct the convex hull of them, and then get and plot the resulting faces (simplices). The problem is that many simplices are coplanar, and they are making the plot very busy for no reason (see all of these diagonal edges in the plot below). Is there any easy way to just

Changing position of axes in Axes3D

帅比萌擦擦* 提交于 2019-12-24 08:25:05
问题 I am using mplot3d from the mpl_toolkits library. When displaying the 3D surface on the figure I'm realized the axis were not positioned as I wished they would. Let me show, I have added to the following screenshot the position of each axis: Is there a way to change the position of the axes in order to get this result: Here's the working code: import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.mplot3d import Axes3D ax = Axes3D(plt.figure()) def f(x,y) : return -x**2 - y**2 X

matplotlib plot_surface for 2-dimensional multiple linear regression

▼魔方 西西 提交于 2019-12-24 07:59:23
问题 I have many points of data with three dimensions: x1, x2, and y. I'm able to calculate the multiple linear regression of these points, and I'm able to display the points on a 3D scatter plot, but I don't know how to plot the multiple linear regression I calculated for those points: the same way you can plot a line of best fit in a 1D linear regression, I'm interested in plotting a "plane of best fit" for a 2D linear regression. My code follows: import numpy as np from mpl_toolkits.mplot3d

Drawing a rectangle or bar between two points in a 3D scatter plot in Python and matplotlib

时光怂恿深爱的人放手 提交于 2019-12-23 13:28:32
问题 I have a 3D scatter plot which, on one of its planes, plots 2 points for each date. I've asked about how to draw a LINE between every pair of points, and received an answer for which I'm thankful. What I want now is to draw a BAR or a RECTANGLE to connect the points instead of just a line. Here's what the plot looks like at the moment, but I want it to look a bit like the plot from the 3D bar demo from matplolib's docs except with the bars "floating" instead of anchored to the axis. I've

Python - Line colour of 3D parametric curve

穿精又带淫゛_ 提交于 2019-12-23 03:54:09
问题 I have 2 lists tab_x (containe the values of x) and tab_z (containe the values of z) which have the same length and a value of y . I want to plot a 3D curve which is colored by the value of z. I know it's can be plotted as a 2D plot but I want to plot a few of these plot with different values of y to compare so I need it to be 3D. My tab_z also containe negatives values I've found the code to color the curve by time (index) in this question but I don't know how to transforme this code to get