mplot3d

Given a set of triangle vertices and faces, separate objects and form separate meshes

点点圈 提交于 2020-06-23 08:52:25
问题 Edit: I have written a more succinct version of this question here but I am keeping this post because it is a full explanation. Given a 3D numpy array, marching cubes can form a 3D object around some threshold. import numpy as np from skimage import measure A = np.zeros((12,12,12)) #A[A<1] = -1 for i in np.arange(1,2): for j in np.arange(1,2): for k in np.arange(1,2): A[i,j,k] = 10 for i in np.arange(8,9): for j in np.arange(8,9): for k in np.arange(8,9): A[i,j,k] = 10 verts, faces, normals,

Color-mapping a 3D quiver function using matplotlib

纵饮孤独 提交于 2020-06-22 12:57:30
问题 I have created a lovely 3D displacement vector field in python using Matplotlib and I am happy with the results. However, visually it is not very east to see the magnitude of the displacements only the direction. Is there a way in python that I could use a colour scale for the arrows so that the magnitude of the displacements is clearer/more visible. This is what I have so far #%% Import Libraries from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np #%%

Reduce height of subplot in Matplotlib

大兔子大兔子 提交于 2020-01-24 22:57:08
问题 I have the following figure composed of grid with 1 row and 2 columns. I would like to reduce the height of the subplot on the right side (3D PREDICTION) so that the chessboard plane looks a little bit squeezed and shows a better perspective. add some margin at the top of the subplot on the left side (2D PREDICTION) so that the title is aligned with the one of 3D PREDICTION Any idea how to do this please? Here is the code to output the image above import matplotlib.gridspec as gridspec import

Remove border from matplotlib 3D pane

我的未来我决定 提交于 2020-01-24 14:04:07
问题 I would like to remove the borders from my 3D scene as described below. Any idea how to do that? Here the code to generate the current scene: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D # Create figure plt.style.use('dark_background') # Dark theme fig = plt.figure() ax = fig.add_subplot(111, projection='3d') # Make panes transparent ax.xaxis.pane.fill = False # Left pane ax.yaxis.pane.fill = False # Right pane # Remove grid lines ax.grid(False) # Remove tick labels

Plotting multiple 3D lines: data transformation

£可爱£侵袭症+ 提交于 2020-01-14 05:11:08
问题 I would like to plot multiple lines in a 3D plot in Python. My input consists of two n x 3 arrays, say pos1 and pos2, corresponding to two lists of 3D points (row = x,y,z coordinates). I need to plot a line connecting the ith point in pos1 to the ith point in pos2, for each i. I have working code, but I am certain that it is terrible and that there is a much better way to implement this. from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np # get plot set

Trying to plot multivariate function in 3D matplotlib; returns empty figure

倖福魔咒の 提交于 2020-01-05 05:48:06
问题 I am trying to plot a function F(x1,x2) in 3D matplotlib, follwoing a tutorial from here: http://glowingpython.blogspot.com/2012/01/how-to-plot-two-variable-functions-with.html Once I try to run the code, the figure turns out to be empty, not even the axes output is seen. I was wondering if anyone could figure out the resaon behind this behavior. I am using python 2.7 from __future__ import division from numpy import exp,arange from pylab import meshgrid,cm,imshow,contour,clabel,colorbar,axis

Using meshgrid to convert X,Y,Z triplet to three 2D arrays for surface plot in matplotlib

﹥>﹥吖頭↗ 提交于 2020-01-04 06:31:21
问题 I'm new to Python so please be patient. I appreciate any help! What I have: three 1D lists ( xr, yr, zr ), one containing x-values, the other two y- and z-values What I want to do: create a 3D contour plot in matplotlib I realized that I need to convert the three 1D lists into three 2D lists, by using the meshgrid function. Here's what I have so far: xr = np.asarray(xr) yr = np.asarray(yr) zr = np.asarray(zr) X, Y = np.meshgrid(xr,yr) znew = np.array([zr for x,y in zip(np.ravel(X), np.ravel(Y