wire3d
3D线框图线框图的一个非常基本的演示。 1234567891011121314from mpl_toolkits.mplot3d import axes3dimport matplotlib.pyplot as pltfig = plt.figure()ax = fig.add_subplot(111, projection='3d')# Grab some test data.X, Y, Z = axes3d.get_test_data(0.05)# Plot a basic wireframe.ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10)plt.show() 下载这个示例 下载python源码: wire3d.py 下载Jupyter notebook: wire3d.ipynb
voxels_torus
具有圆柱坐标的3D体素/体积图演示使用ax.voxels的x,y,z参数。 1234567891011121314151617181920212223242526272829303132333435363738394041import matplotlib.pyplot as pltimport matplotlib.colorsimport 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# pre...
wire3d_zero_stride
三维线框在一个方向上绘制证明将rstride或cstride设置为0会导致在相应方向上不生成导线。 12345678910111213141516171819from mpl_toolkits.mplot3d import axes3dimport matplotlib.pyplot as pltfig, [ax1, ax2] = plt.subplots(2, 1, figsize=(8, 12), subplot_kw={'projection': '3d'})# Get the test dataX, Y, Z = axes3d.get_test_data(0.05)# Give the first plot only wireframes of the type y = cax1.plot_wireframe(X, Y, Z, rstride=10, cstride=0)ax1.set_title("Column (x) stride set to 0")# Give the second ...
wire3d_animation_sgskip
旋转3D线框图一个非常简单的3D动画“动画”。 另请参见rotate_axes3d_demo。 (构建文档库时会跳过此示例,因为它有意运行需要很长时间) 1234567891011121314151617181920212223242526272829303132333435363738394041# 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 npimport timedef generate(X, Y, phi): ''' Generates Z data for the points in the X, Y meshgrid and parameter phi. ''' R = 1 ...
pie_and_donut_labels
标记饼图和空心饼图欢迎来到Matplotlib面包店。我们将通过 pie 方法 (pie method) 创建一个饼图和一个空心饼图表,并展示如何使用图例和注释来标记它们。 与往常一样,我们将从定义导入开始,并创建一个带有子图的图形。现在是吃派的时候了。从饼图开始,我们从数据和标签列表中创建数据。 我们可以为autopct参数提供一个函数,它将通过显示绝对值来扩展自动百分比标记;我们从相对数据和已知的所有值之和计算出后者。 然后,我们创建饼图并存储返回的对象以供日后使用。返回元组的第一个返回元素是楔形列表。这些是matplotlib.patches.WEdge 补丁,可以直接用作图例的句柄。我们可以使用图例的bbox_to_anchor参数将图例放在饼图之外。这里我们使用轴坐标(1,0,0.5,1)和“中间左”的位置;即图例的左中心点位于边界框的左中心点,在轴坐标中从(1,0)到(1.5,1)。 然后我们创建馅饼并存储返回的对象,以备以后使用。返回的元组的第一个返回元素是楔体列表。这些是matplotlib.patches.WEdge 面片,可以直接用作图例的句柄。我们可以使用图...
nested_pie
嵌套饼图以下示例显示了在Matplotlib中构建嵌套饼图的两种方法。 这些图表通常被称为空心饼图图表。 12import matplotlib.pyplot as pltimport numpy as np 构建饼图最简单的方法是使用饼图方法(pie method)。 在这种情况下,pie获取与组中的计数相对应的值。我们将首先生成一些假数据,对应三组。在内圈中,我们将每个数字视为属于自己的组。 在外圈,我们将它们绘制为原始3组的成员。 空心饼图形状的效果是通过wedgeprops参数设置馅饼楔形的宽度来实现的。 1234567891011121314151617fig, ax = plt.subplots()size = 0.3vals = np.array([[60., 32.], [37., 40.], [29., 10.]])cmap = plt.get_cmap("tab20c")outer_colors = cmap(np.arange(3)*4)inner_colors = cmap(np.array([1, 2, 5, 6, 9, 10]))...
pie_demo2
Pie 绘制饼图演示使用 pie(). 制作饼图。 此示例演示了一些饼图功能,如标签、可变大小、自动标记百分比、偏移切片和添加阴影。 1234567891011121314151617181920212223242526272829303132333435import matplotlib.pyplot as plt# Some datalabels = 'Frogs', 'Hogs', 'Dogs', 'Logs'fracs = [15, 30, 45, 10]# Make figure and axesfig, axs = plt.subplots(2, 2)# A standard pie plotaxs[0, 0].pie(fracs, labels=labels, autopct='%1.1f%%', shadow=True)# Shift the second slice using explodeaxs[0, 1].pie(fracs, labels=labels, ...
pie_features
基本饼图演示一个基本的饼图和一些额外的功能。 除了基本饼图外,此演示还显示了以下几个可选功能: 切片标签。 自动标记百分比。 用 explode 偏移切片。 投影。 自定义起始角度 请注意,自定义起点角度: 默认的起始角度(startangle)为0,这将在正x轴上开始“Frogs”切片。此示例将 startangle设置为90 ,以便将所有对象逆时针旋转90度,并且青蛙切片从正y轴开始。 12345678910111213import matplotlib.pyplot as plt# Pie chart, where the slices will be ordered and plotted counter-clockwise:labels = 'Frogs', 'Hogs', 'Dogs', 'Logs'sizes = [15, 30, 45, 10]explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i....
polar_bar
极轴上的饼图极轴上的饼状条形图演示。 12345678910111213141516171819202122import numpy as npimport matplotlib.pyplot as plt# Fixing random state for reproducibilitynp.random.seed(19680801)# Compute pie slicesN = 20theta = np.linspace(0.0, 2 * np.pi, N, endpoint=False)radii = 10 * np.random.rand(N)width = np.pi / 4 * np.random.rand(N)ax = plt.subplot(111, projection='polar')bars = ax.bar(theta, radii, width=width, bottom=0.0)# Use custom colors and opacityfor r, bar in zip(radii, bars): bar.set_facec...
polar_demo
极轴上绘制线段在极轴上绘制线图的演示。 12345678910111213141516import numpy as npimport matplotlib.pyplot as pltr = np.arange(0, 2, 0.01)theta = 2 * np.pi * rax = plt.subplot(111, projection='polar')ax.plot(theta, r)ax.set_rmax(2)ax.set_rticks([0.5, 1, 1.5, 2]) # Less radial ticksax.set_rlabel_position(-22.5) # Move radial labels away from plotted lineax.grid(True)ax.set_title("A line plot on a polar axis", va='bottom')plt.show() 参考本示例中显示了以下函数,方法,类和模块的使用: 1234567import matplotli...














