mplot3d

Changing grid line thickness in 3D surface plot in Python Matplotlib

心已入冬 提交于 2019-12-06 11:11:03
问题 I'm trying to change the thickness and transparency of the lines that make up the grid in the background of a surface plot like this example from Matplotlib's website: Here's the source code: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib import cm from matplotlib.ticker import LinearLocator, FormatStrFormatter import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') # Make data. X = np.arange(-5, 5, 0.25) Y = np.arange(-5, 5, 0.25) X, Y =

change view, plot3D, Julia language (similar to matplotlib)

為{幸葍}努か 提交于 2019-12-06 09:05:23
问题 I'm trying to change the perspective of a 3D scatter plot. (Julia Language) This code, for example, changes the perspective, but the points are plotted individually with each change, rather than together. for i=1:10 X=i; Y=i+2; Z = i+3 fig = figure() ax = gca(projection="3d") plot3D([X],[Y],[Z], ".") ax[:view_init](30, 180) end How can I write this so that I see all the points together in a changed perspective? The format in Julia is adapted from matplotlib, so it should be very similar to

3D parametric curve in Matplotlib does not respect zorder. Workaround?

让人想犯罪 __ 提交于 2019-12-06 06:04:41
I am designing a three-dimensional illustration using Matplotlib. All is working nicely, except that the (red) parametric curve gets the wrong zorder while the (green) parametric surface is drawn completely correctly. Output generated by code below: I know that Matplotlib has limited capabilities for accurately computing the zorder of objects, but since it can do it for the parametric surface, it seems like a bug in Matplotlib. That said, is there any way to force correct z-ordering just to get things to work quickly? It seems that all I have to be able to say is that the right transparent

Python 3d Pyramid

只谈情不闲聊 提交于 2019-12-06 02:49:17
I'm new to 3d plotting. I just want to build a pyramid out of 5 Points and cut a plane through it. My problem is I don't know how to fill the sides. points = np.array([[-1, -1, -1], [1, -1, -1 ], [1, 1, -1], [-1, 1, -1], [0, 0 , 1]]) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') r = [-1,1] X, Y = np.meshgrid(r, r) ax.plot_surface(X,Y,-1, alpha=0.5) ax.plot_surface(X,Y,0.5, alpha=0.5, facecolors='r') ax.scatter3D(points[:, 0], points[:, 1], points[:, 2]) ax.set_xlabel('X') ax.set_ylabel('Y') ax.set_zlabel('Z') plt.show() Any help is appreciated. You have to use polygons: from

How to visualize 3D delaunay triangulation in Python?

蹲街弑〆低调 提交于 2019-12-05 16:22:25
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? nullas 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]]) mlab.triangular_mesh(vertices[0,:], vertices[1,:], vertices[2,:], faces.T) mlab.show() It can also

Scaled colormap of facecolors with mplot3d

时光怂恿深爱的人放手 提交于 2019-12-05 06:43:16
I have a simple task that should have a simple solution, but I have been trying for days now. I try to be specific. I try to plot a surface using matplotlib's mplot3d and plot_surface. When I plot the surface of a dataset 'z' and try to scale the colormap to a certain maximum value I change the 'vmax' property to this value. That works great. When I try to plot a surface of one dataset (z) and use the facecolors of a second dataset (fc), this also works fine. When I want to scale the colormap of the facecolors, the vmax property is overruled by the facecolors values. Vmax therefore has no

Adding colors to a 3d quiver plot in matplotlib

丶灬走出姿态 提交于 2019-12-05 04:25:55
I want to have colors corresponding to a colormap in my 3d quiver plot. The 2d version of the plot has an optional array that is used to map colors to the arrows. How can I create the same effect in the 3d version? 3D quiver plots are a brand-new feature in 1.4 it (and it's documentation) might still be a bit rough around the edges. In this case we can try to use the fact that the quiver is implemented as a LineCollection which (eventually) inherits from ScalarMappable which means it knows what a colormap is and the returned artist has the method set_array . Building on the docs here from mpl

Animating 3D scatter plot using Python mplotlib via serial data

情到浓时终转凉″ 提交于 2019-12-04 18:34:23
I am trying to animate a 3D scatter plot using mplotlib in Python. I am able to graph the data and redraw every time, but this results in a frame rate of less than 1 FPS, and I need to scale to upwards of 30 FPS. When I run my code: import serial import numpy import matplotlib.pyplot as plt #import matplotlib library from mpl_toolkits.mplot3d import Axes3D from drawnow import * import matplotlib.animation import time ser = serial.Serial('COM7',9600,timeout=5) ser.flushInput() time.sleep(5) ser.write(bytes(b's1000')) x=list() y=list() z=list() #plt.ion() fig = plt.figure(figsize=(16,12)) ax =

Changing grid line thickness in 3D surface plot in Python Matplotlib

旧城冷巷雨未停 提交于 2019-12-04 15:23:46
I'm trying to change the thickness and transparency of the lines that make up the grid in the background of a surface plot like this example from Matplotlib's website : Here's the source code: from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt from matplotlib import cm from matplotlib.ticker import LinearLocator, FormatStrFormatter import numpy as np fig = plt.figure() ax = fig.gca(projection='3d') # Make data. X = np.arange(-5, 5, 0.25) Y = np.arange(-5, 5, 0.25) X, Y = np.meshgrid(X, Y) R = np.sqrt(X**2 + Y**2) Z = np.sin(R) # Plot the surface. surf = ax.plot_surface(X,

Matplotlib 3D Bar chart: axis issue

删除回忆录丶 提交于 2019-12-04 14:04:48
问题 I am having issue with getting data on x,y,z axis..below is my code. Is there any issue with the way i have defined range(dx,dy.dz) for different axis. result=[['122', '109', '2343', '220', '19'], ['15', '407', '37', '10', '102'], ['100', '100', '100', '100', '100'], ['113', '25', '19', '31', '112'], ['43', '219', '35', '33', '14'], ['132', '108', '256', '119', '14'], ['22', '48', '352', '51', '438']] from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import matplotlib