3d_bars
3D条形图演示有关如何使用和不使用着色绘制3D条形图的基本演示。 12345678910111213141516171819202122232425262728import numpy as npimport matplotlib.pyplot as plt# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import# setup the figure and axesfig = plt.figure(figsize=(8, 3))ax1 = fig.add_subplot(121, projection='3d')ax2 = fig.add_subplot(122, projection='3d')# fake data_x = np.arange(4)_y = np.arange(5)_xx, _yy = np.meshgrid(...
bars3d
在不同的平面中创建二维条形图演示制作3D绘图,其中2D条形图投影到平面y = 0,y = 1等。 123456789101112131415161718192021222324252627282930313233343536# 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 np# Fixing random state for reproducibilitynp.random.seed(19680801)fig = plt.figure()ax = fig.add_subplot(111, projection='3d')colors = ['r', 'g', 'b', &...
contour3d_2
演示使用extend3d选项在3D中绘制轮廓(水平)曲线contour3d_demo示例的这种修改使用extend3d = True将曲线垂直扩展为“ribbon”。 12345678910111213from mpl_toolkits.mplot3d import axes3dimport matplotlib.pyplot as pltfrom matplotlib import cmfig = plt.figure()ax = fig.gca(projection='3d')X, Y, Z = axes3d.get_test_data(0.05)cset = ax.contour(X, Y, Z, extend3d=True, cmap=cm.coolwarm)ax.clabel(cset, fontsize=9, inline=1)plt.show() 下载这个示例 下载python源码: contour3d_2.py 下载Jupyter notebook: contour3d_2.ipynb
contour3d_3
将轮廓轮廓投影到图形上演示显示3D表面,同时还将轮廓“轮廓”投影到图形的“墙壁”上。 有关填充版本,请参见contourf3d_demo2。 123456789101112131415161718192021222324252627from mpl_toolkits.mplot3d import axes3dimport matplotlib.pyplot as pltfrom matplotlib import cmfig = plt.figure()ax = fig.gca(projection='3d')X, Y, Z = axes3d.get_test_data(0.05)# Plot the 3D surfaceax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)# Plot projections of the contours for each dimension. By choosing offsets# that match the appropriate axes limit...
contourf3d
填充轮廓contourf与轮廓的不同之处在于它创建了填充轮廓,即。 离散数量的颜色用于遮蔽域。 这类似于2D中的等高线图,除了对应于等级c的阴影区域在平面z = c上绘制图形。 12345678910111213from mpl_toolkits.mplot3d import axes3dimport matplotlib.pyplot as pltfrom matplotlib import cmfig = plt.figure()ax = fig.gca(projection='3d')X, Y, Z = axes3d.get_test_data(0.05)cset = ax.contourf(X, Y, Z, cmap=cm.coolwarm)ax.clabel(cset, fontsize=9, inline=1)plt.show() 下载这个示例 下载python源码: contourf3d.py 下载Jupyter notebook: contourf3d.ipynb
custom_shaded_3d_surface
3D表面图中的自定义山体的阴影演示在3D曲面图中使用自定义山体阴影。 1234567891011121314151617181920212223242526272829303132# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importfrom matplotlib import cbookfrom matplotlib import cmfrom matplotlib.colors import LightSourceimport matplotlib.pyplot as pltimport numpy as np# Load and format datafilename = cbook.get_sample_data('jacksboro_fault_dem.npz', asfileobj=False)with np.load(filename...
contourf3d_2
将填充轮廓投影到图形上演示显示3D表面,同时还将填充的轮廓“轮廓”投影到图形的“墙壁”上。 有关未填充的版本,请参见contour3d_demo2。 123456789101112131415161718192021222324252627from mpl_toolkits.mplot3d import axes3dimport matplotlib.pyplot as pltfrom matplotlib import cmfig = plt.figure()ax = fig.gca(projection='3d')X, Y, Z = axes3d.get_test_data(0.05)# Plot the 3D surfaceax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)# Plot projections of the contours for each dimension. By choosing offsets# that match the appropriate axes l...
lines3d
参数曲线此示例演示了如何在3D中绘制参数曲线。 1234567891011121314151617181920212223# This import registers the 3D projection, but is otherwise unused.from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused importimport numpy as npimport matplotlib.pyplot as pltplt.rcParams['legend.fontsize'] = 10fig = plt.figure()ax = fig.gca(projection='3d')# Prepare arrays x, y, ztheta = np.linspace(-4 * np.pi, 4 * np.pi, 100)z = np.linspace(-2, 2, 100)r = z**2 + 1x = r * np.sin(theta)y = r * np.cos(the...
hist3d
创建2D数据的3D直方图将二维数据的直方图演示为3D中的条形图。 12345678910111213141516171819202122232425262728# 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 np# Fixing random state for reproducibilitynp.random.seed(19680801)fig = plt.figure()ax = fig.add_subplot(111, projection='3d')x, y = np.random.rand(2, 100) * 4hist, xedges, yedges = np.histogram2d(x, y, bins=4, range=[[0, 4]...
mixed_subplots
相同图中的2D和3D轴此示例显示如何在同一图上绘制2D和3D绘图。 12345678910111213141516171819202122232425262728293031323334353637383940414243# 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 npdef f(t): s1 = np.cos(2*np.pi*t) e1 = np.exp(-t) return np.multiply(s1, e1)# Set up a figure twice as tall as it is widefig = plt.figure(figsize=plt.figaspect(2.))fig.suptitle('A tale of 2...














