Python 使用极轴在matplotlib中进行四倍显示
我正在尝试在matplotlib中创建一个: 但无法得到极轴的逻辑。这就是我迄今为止所尝试的:Python 使用极轴在matplotlib中进行四倍显示,python,python-2.7,matplotlib,Python,Python 2.7,Matplotlib,我正在尝试在matplotlib中创建一个: 但无法得到极轴的逻辑。这就是我迄今为止所尝试的: 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(1
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]、[90180]、[180,270]、[270,360]
- 我不明白“宽度”对应什么
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()
您将得到您所期望的:
另一方面,对于您正在制作的确切绘图,在具有中心棘的矩形绘图上使用4个
楔块可能更有意义。如果其他人感兴趣,我会想到这一点。
import numpy as np
x1 = np.array([
[1198, 1493],
[557, 1278]
])
x2 = ContTableIPFP(x1).flatten()
FourfoldDisplay(x2)
要使用本文中伯克利录取的例子,首先需要使用
然后策划
def FourfoldDisplay(radii):
''' radii = [10, 15, 20, 25]
'''
import numpy as np
import matplotlib.pyplot as plt
# 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)
#labels
ax.set_xticklabels([])
ax.set_yticks([])
#plt.axis('off')
plt.show()
使用
import numpy as np
x1 = np.array([
[1198, 1493],
[557, 1278]
])
x2 = ContTableIPFP(x1).flatten()
FourfoldDisplay(x2)
伟大的谢谢我不知道你说的“4楔”是什么意思。