我正在尝试绘制极坐标图,表示一半方向。我正在使用ax.set_thetalim
,似乎无法弄清楚如何使用“饼图的另一半”(即,从342到162,包括90度,但不包括270度)。我试图使limss徒劳无功。
from matplotlib import pyplot as plt
fig = plt.figure(figsize=(11,11))
ax = plt.subplot(111, polar=True)
lims2 = [342, 162]
ax.set_thetalim(np.deg2rad(lims1))
ax.set_theta_direction(-1)
ax.set_theta_zero_location('N')
from matplotlib import pyplot as plt
fig = plt.figure(figsize=(11,11))
ax = plt.subplot(111, polar=True)
lims2 = [162,342]
ax.set_thetalim(np.deg2rad(lims1))
ax.set_theta_direction(-1)
ax.set_theta_zero_location('N')
答案 0 :(得分:2)
要显示极坐标图的另一半,您需要将极限设置为-18至162。
import numpy as np
from matplotlib import pyplot as plt
fig, (ax1, ax2) = plt.subplots(ncols=2, figsize=(11,6), subplot_kw=dict(polar=True))
for ax in (ax1, ax2):
ax.set_theta_direction(-1)
ax.set_theta_zero_location('N')
lims1 = [342, 162]
lims2 = [-18, 162]
ax1.set_thetalim(np.deg2rad(lims1))
ax2.set_thetalim(np.deg2rad(lims2))
plt.show()