为什么我的学位争论表现得很奇怪?
Why is my degree argument behaving weirdly?
所以这是我的代码 运行
#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
,但问题仍然存在。
度数参数是度数还是其他(弧度)?如果那不是问题,我做错了什么?
您必须以弧度为单位传递角度。而且,你的身高只有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])
所以这是我的代码 运行
#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
,但问题仍然存在。
度数参数是度数还是其他(弧度)?如果那不是问题,我做错了什么?
您必须以弧度为单位传递角度。而且,你的身高只有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])