def plot_polar(theta, N):
"""Plot polar plot.
theta -- the dataframe with the turning angles
N -- number of bins to use
"""
hist, bins = np.histogram(theta.ta, bins=N)
# the width of the bins interval
width = [t - s for s, t in zip(bins, bins[1:])]
bins_ = bins[0:N] # exclude the last value
# the actual plotting logic
g = sns.FacetGrid(theta, size=4)
radii = hist / max(hist)
for ax in g.axes.flat:
ax2 = plt.subplot(111, projection='polar')
bars = ax2.bar(bins_, radii, width, bottom=0.0)
for r, bar in zip(radii, bars):
bar.set_facecolor(plt.cm.Spectral(r))
bar.set_alpha(0.5)
sns.plt.savefig("turning_angles.png")
评论列表
文章目录