这就是我正在运行的代码
#Pass Sonar
import numpy as np
import matplotlib.pyplot as plt
#Entering Data
# angles of all the passes
theta = [45]
heights = [5]
# length of all the passes
# Getting axes handles/objects
ax1 = plt.subplot(111, polar=True)
# Plot
bars = ax1.bar(theta, heights,
color='xkcd:orangered',
#color=plt.cm.jet(heights),
width=0.1,
#width=heights,
bottom=0.0,
edgecolor='k',
alpha=0.5,
label='All Passes>2 mts')
##Main tweaks
# Radius limits
ax1.set_ylim(0, 7.0)
# Radius ticks
ax1.set_yticks(np.linspace(0, 7.0, 8))
# Radius tick position in degrees
ax1.set_rlabel_position(315)
#Angle ticks
ax1.set_xticks(np.linspace(0, 2.0*np.pi, 9)[:-1])
#Additional tweaks
plt.grid(True)
plt.legend()
plt.title("Pass Sonar: Mesut Özil v/s Leicester City - 22.10.2018")
plt.show()
因此,我使用45作为度数参数,但条形图以58度打印?输入90将使标准线处于115 ish。我也尝试过使用linspace
,问题仍然存在。
度数参数是度数还是其他(弧度)?如果那不是问题,那我在做什么错?
答案 0 :(得分:2)
您必须以弧度为单位传递角度。此外,您的身高仅为5度,即0.087弧度。然后,您将y限制设置为0到7弧度。在这个比例尺上看不到这么低的高度。因此,您需要删除ax1.set_ylim(0, 7.0)
并使用较小的y上限,例如0.1。
import numpy as np
import matplotlib.pyplot as plt
import math
# angles of all the passes
theta = [math.radians(45)]
heights = [math.radians(5)]
# length of all the passes
# Getting axes handles/objects
ax1 = plt.subplot(111, polar=True)
# Plot
bars = ax1.bar(theta, heights,
color='xkcd:orangered',
#color=plt.cm.jet(heights),
width=0.1,
#width=heights,
bottom=0.0,
edgecolor='k',
alpha=0.5,
label='All Passes>2 mts')
##Main tweaks
# Radius limits
ax1.set_ylim(0, 0.1)
ax1.set_rlabel_position(315)
#Angle ticks
ax1.set_xticks(np.linspace(0, 2.0*np.pi, 9)[:-1])