python - 使用极轴在 matplotlib 中进行四重显示

标签 python python-2.7 matplotlib

我正在尝试创建一个 fourfold display在 matplotlib 中:

enter image description here

但是获取不到极轴的逻辑。到目前为止,这是我尝试过的:

import numpy as np
import matplotlib.pyplot as plt

# radius of each bar 
radii = [10,  15, 20, 25] 

# Value - width 
width = np.pi/ 2 

# angle of each bar 
theta = [0,90,180,270]

ax = plt.subplot(111, polar=True)
bars = ax.bar(theta, radii, width=width)
plt.show()

不确定我缺少什么,但我只想要四个相互接触的“相等”区域。我无法上类的是

  • 如何“控制”角度?我的意思是让所有四张“幻灯片”都在 [0,90]、[90,180]、[180, 270]、[270, 360] 中。

  • 我不明白“width”对应的是什么。

最佳答案

theta 应以弧度为单位,而不是度数。

如果您只是稍微调整一下代码:

import numpy as np
import matplotlib.pyplot as plt

# radius of each bar
radii = [10,  15, 20, 25]

# Value - width
width = np.pi/ 2

# angle of each bar
theta = np.radians([0,90,180,270])

ax = plt.subplot(111, polar=True)
bars = ax.bar(theta, radii, width=width, alpha=0.5)
plt.show()

你会得到你所期望的:

enter image description here

旁注,对于您正在制作的确切图,在脊柱居中的矩形图上使用 4 个楔形可能更有意义。

关于python - 使用极轴在 matplotlib 中进行四重显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22306555/

相关文章:

python - opencv 与 python 模块有不同的版本

python - 如何在 win32com 中迭代工作表?

python - 快速 numpy rolling_product

python - 使用 matplotlib 绘制交互式直方图?

matplotlib - 如何将 matplotlib Figure 对象包含为子图?

python - 在上下文管理器中捕获 threading.Timer 抛出的异常

python - 如何使用 'os' 从 'with' 打开文件对象?

python - Azure 数字孪生 Python API - 创建了模型孪生,但无法检索它

Python:将numpy数组(int)写入二进制文件而不进行填充

python - 在 python 中绘制填充的多边形