极坐标轴上的误差条渲染#

极坐标中误差条图的演示.Theta 误差条是弯曲的线条,末端带有朝向中心的帽.半径误差条是朝向中心的直线,带有垂直帽.

import matplotlib.pyplot as plt
import numpy as np

theta = np.arange(0, 2 * np.pi, np.pi / 4)
r = theta / np.pi / 2 + 0.5

fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(projection='polar')
ax.errorbar(theta, r, xerr=0.25, yerr=0.1, capsize=7, fmt="o", c="seagreen")
ax.set_title("Pretty polar error bars")
plt.show()
Pretty polar error bars

请注意,大的 theta 误差条会重叠.这可能会降低输出图的可读性.请参见下面的示例图:

fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(projection='polar')
ax.errorbar(theta, r, xerr=5.25, yerr=0.1, capsize=7, fmt="o", c="darkred")
ax.set_title("Overlapping theta error bars")
plt.show()
Overlapping theta error bars

另一方面,大的半径误差条永远不会重叠,它们只会导致数据中出现不必要的比例,从而减少显示的范围.

fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(projection='polar')
ax.errorbar(theta, r, xerr=0.25, yerr=10.1, capsize=7, fmt="o", c="orangered")
ax.set_title("Large radius error bars")
plt.show()
Large radius error bars

参考

以下函数,方法,类和模块的用法在本例中显示:

  • matplotlib.axes.Axes.errorbar / matplotlib.pyplot.errorbar

  • matplotlib.projections.polar

标签:component: error plot-type: errorbar plot-type: polar level: beginner

脚本的总运行时间:(0 分 1.589 秒)

Gallery generated by Sphinx-Gallery