python - 如何限制 matplotlib 极坐标图中的轴

标签 python matplotlib polar-coordinates

我正在尝试使用 matplotlib 极坐标图绘制一 block 饼图,如下所示:

Fig, ax = pyplot.subplots(subplot_kw=dict(polar=True))
ax.bar(math.pi/3.0, 5.0, width=math.pi/3.0)
ax.bar(math.pi/3.0, 3.0, width=math.pi/3.0)

# Adjust the axis
ax.set_ylim(math.pi/3.0, 2*math.pi/3.0)

我只想查看 math.pi/3.02*math.pi/3.0 之间的图表部分。这可能吗?

最佳答案

我不确定您在寻找什么,但如果您只想查看其中的一部分,您可以这样做:

import matplotlib.pyplot as plt
import math

Fig, ax = plt.subplots(subplot_kw=dict(polar=True))
ax.bar(math.pi/3.0, 5.0, width=math.pi/3.0)
ax.bar(math.pi/3.0, 3.0, width=math.pi/3.0)

# Adjust the axis
ax.set_ylim(math.pi/3.0, 2*math.pi/3.0)

ax.set_frame_on(False)
ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)
plt.show()

关于python - 如何限制 matplotlib 极坐标图中的轴,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16846481/

相关文章:

python - 如何减少或以其他方式影响极坐标图中的径向刻度数?

Python:通过通配符获取内存缓存键值列表

python - Pylons:与外部库共享 SQLAlchemy MySQL 连接

python - Ginput 为 datetimeindex 提供了错误的日期

Python Matplotlib - 使用 Imsave 强加形状尺寸

python - 风玫瑰图的自定义缩放

python - 如何让 pylint 通过 astroid 识别变量

python - 如何处理旧数据迁移中缺失列的情况?

python - 如何同时绘制不同产品的时间序列图?

java - 沿着螺旋线移动到中心,笛卡尔坐标在开始时给出