surface3d_3
三维曲面(棋盘格)演示绘制以棋盘图案着色的3D表面。 123456789101112131415161718192021222324252627282930313233343536# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importimport matplotlib.pyplot as pltfrom matplotlib.ticker import LinearLocatorimport numpy as npfig = plt.figure()ax = fig.gca(projection='3d')# Make data.X = np.arange(-5, 5, 0.25)xlen = len(X)Y = np.arange(-5, 5, 0.25)ylen = len(Y)X, Y = np.meshgrid(X, Y)R = np.sq...
surface3d_radial
极坐标下的三维曲面演示绘制在极坐标中定义的曲面。使用YlGnBu颜色映射的反转版本。还演示了使用乳胶数学模式编写轴标签。 示例由Armin Moser提供。 1234567891011121314151617181920212223242526272829# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importimport matplotlib.pyplot as pltimport numpy as npfig = plt.figure()ax = fig.add_subplot(111, projection='3d')# Create the mesh in polar coordinates and compute corresponding Z.r = np.linspace(0, 1.25, 50)p = np.linspace(0, 2...
text3d
三维中的文字注释演示在3D绘图上放置文本注释。 显示的功能: 使用具有三种“zdir”值的文本函数:无,轴名称(例如’x’)或方向元组(例如(1,1,0))。 使用带有color关键字的文本功能。 使用text2D函数将文本放在ax对象上的固定位置。 1234567891011121314151617181920212223242526272829303132333435# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importimport matplotlib.pyplot as pltfig = plt.figure()ax = fig.gca(projection='3d')# Demo 1: zdirzdirs = (None, 'x', 'y', 'z', (1, 1, 0), ...
trisurf3d
三角三维曲面用三角形网格绘制3D表面。 1234567891011121314151617181920212223242526272829# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importimport matplotlib.pyplot as pltimport numpy as npn_radii = 8n_angles = 36# Make radii and angles spaces (radius r=0 omitted to eliminate duplication).radii = np.linspace(0.125, 1.0, n_radii)angles = np.linspace(0, 2*np.pi, n_angles, endpoint=False)[..., np.newaxis]# Convert polar (radii, angl...
tricontour3d
三角形三维等高线图非结构化三角形网格的等高线图。 使用的数据与trisurf3d_demo2的第二个图中的数据相同。 tricontourf3d_demo显示此示例的填充版本。 12345678910111213141516171819202122232425262728293031323334353637# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importimport matplotlib.pyplot as pltimport matplotlib.tri as triimport numpy as npn_angles = 48n_radii = 8min_radius = 0.25# Create the mesh in polar coordinates and compute x, y, z.radii = np.linspace(min_radius,...
tricontourf3d
三角形三维填充等高线图非结构化三角形网格的填充等高线图。 使用的数据与trisurf3d_demo2的第二个图中的数据相同。 tricontour3d_demo显示此示例的未填充版本。 1234567891011121314151617181920212223242526272829303132333435363738# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importimport matplotlib.pyplot as pltimport matplotlib.tri as triimport numpy as np# First create the x, y, z coordinates of the points.n_angles = 48n_radii = 8min_radius = 0.25# Create the mesh in polar coor...
trisurf3d_2
多三角三维曲面使用三角形网格绘制曲面的另外两个示例。 第一个演示使用plot_trisurf的三角形参数,第二个设置Triangulation对象的蒙版并将对象直接传递给plot_trisurf。 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970import numpy as npimport matplotlib.pyplot as pltimport matplotlib.tri as mtri# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importfig = plt.figure(figsize=plt.figaspect(0.5))#=========...
voxels
三维体素/体积绘制演示使用ax.voxels绘制3D体积对象 123456789101112131415161718192021222324252627282930import matplotlib.pyplot as pltimport numpy as np# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import# prepare some coordinatesx, y, z = np.indices((8, 8, 8))# draw cuboids in the top left and bottom right corners, and a link between themcube1 = (x < 3) & (y < 3) & (z < 3)cube2 = (x >= 5) & (y >= 5)...
voxels_rgb
带有rgb颜色的3D体素/体积图演示使用ax.voxels可视化颜色空间的各个部分 123456789101112131415161718192021222324252627282930313233343536373839import matplotlib.pyplot as pltimport numpy as np# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importdef midpoints(x): sl = () for i in range(x.ndim): x = (x[sl + np.index_exp[:-1]] + x[sl + np.index_exp[1:]]) / 2.0 sl += np.index_exp[:] return x# prepare some coordinates, a...
voxels_numpy_logo
三维体素绘制Numpy的Logo演示使用坐标不均匀的ax.voxels 123456789101112131415161718192021222324252627282930313233343536373839404142import matplotlib.pyplot as pltimport numpy as np# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importdef explode(data): size = np.array(data.shape)*2 data_e = np.zeros(size - 1, dtype=data.dtype) data_e[::2, ::2, ::2] = data return data_e# build up the numpy logon_voxels = np.zeros((4, 3, 4...












