mayavi

python : plotting a wireframe 3D cuboid

早过忘川 提交于 2019-11-28 00:27:19
I want to plot 3d cuboid in python. Input : center (3 points for the center) radius (3 radius values, one for each dimension) Ideally it should be a wireframe plot(I need to see whats inside).I am not exactly sure how to go about this. Using python matplotlib or Mayavi is fine. Thanks! So far I have tried the following code ..but that only draws a cube from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np from itertools import product, combinations fig = plt.figure() ax = fig.gca(projection='3d') ax.set_aspect("equal") #draw cube r = [-1, 1] for s, e in

Animating a mayavi points3d plot

依然范特西╮ 提交于 2019-11-27 22:59:35
I'm trying to make a video of the trajectories of particles. However, somehow my scene never updates. Here's a very simple example: from __future__ import absolute_import, division, print_function from mayavi import mlab import numpy as np import math alpha = np.linspace(0, 2*math.pi, 100) xs = np.cos(alpha) ys = np.sin(alpha) zs = np.zeros_like(xs) mlab.points3d(0,0,0) plt = mlab.points3d(xs[:1], ys[:1], zs[:1]) @mlab.animate(delay=100) def anim(): f = mlab.gcf() while True: for (x, y, z) in zip(xs, ys, zs): print('Updating scene...') plt.mlab_source.x[0] = x plt.mlab_source.y[0] = y plt.mlab

How to plot a 3D density map in python with matplotlib

余生长醉 提交于 2019-11-27 19:48:57
问题 I have a large dataset of (x,y,z) protein positions and would like to plot areas of high occupancy as a heatmap. Ideally the output should look similiar to the volumetric visualisation below, but I'm not sure how to achieve this with matplotlib. My initial idea was to display my positions as a 3D scatter plot and color their density via a KDE. I coded this up as follows with test data: import numpy as np from scipy import stats import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import

Map an image onto a sphere and plot 3D trajectories

倖福魔咒の 提交于 2019-11-27 02:31:35
问题 What I would like to do is to define a sphere in the center of my 3D coordinate system (with radius=1), wrap a cylindrical planet map onto the sphere's surface (i.e. perform texture mapping on the sphere) and plot 3D trajectories around the object (like satellite trajectories). Is there any way I can do this using matplotlib or mayavi? 回答1: Plotting trajectories is easy using mayavi.mlab.plot3d once you have your planet, so I'm going to concentrate on texture mapping a planet to a sphere

How to obscure a line behind a surface plot in matplotlib?

被刻印的时光 ゝ 提交于 2019-11-26 21:02:01
I want to plot data using Matplotlib via a colormap on the surface of a sphere. Additionally, I would like to add a 3D line plot. The code I have so far is this: import matplotlib import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import numpy as np NPoints_Phi = 30 NPoints_Theta = 30 radius = 1 pi = np.pi cos = np.cos sin = np.sin phi_array = ((np.linspace(0, 1, NPoints_Phi))**1) * 2*pi theta_array = (np.linspace(0, 1, NPoints_Theta) **1) * pi phi, theta = np.meshgrid(phi_array, theta_array) x_coord = radius*sin(theta)*cos(phi) y_coord = radius*sin(theta)*sin(phi) z_coord

python : plotting a wireframe 3D cuboid

ⅰ亾dé卋堺 提交于 2019-11-26 17:11:40
问题 I want to plot 3d cuboid in python. Input : center (3 points for the center) radius (3 radius values, one for each dimension) Ideally it should be a wireframe plot(I need to see whats inside).I am not exactly sure how to go about this. Using python matplotlib or Mayavi is fine. Thanks! So far I have tried the following code ..but that only draws a cube from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import numpy as np from itertools import product, combinations fig =