【发布时间】:2012-11-21 16:54:56
【问题描述】:
我正在尝试在极轴上绘制一些直方图数据,但它似乎无法正常工作。下面是一个示例,我使用找到的自定义投影How to make the angles in a matplotlib polar plot go clockwise with 0° at the top? 它适用于散点图,所以我认为我的问题在于直方图函数。这让我整天发疯,有谁知道我做错了什么............
import random
import numpy as np
import matplotlib.pyplot as plt
baz = np.zeros((20))
freq = np.zeros((20))
pwr = np.zeros((20))
for x in range(20):
baz[x] = random.randint(20,25)*10
freq[x] = random.randint(1,10)*10
pwr[x] = random.randint(-10,-1)*10
baz = baz*np.pi/180.
abins = np.linspace(0,2*np.pi,360) # 0 to 360 in steps of 360/N.
sbins = np.linspace(1, 100)
H, xedges, yedges = np.histogram2d(baz, freq, bins=(abins,sbins), weights=pwr)
plt.figure(figsize=(14,14))
plt.subplot(1, 1, 1, projection='northpolar')
#plt.scatter(baz, freq)
plt.pcolormesh(H)
plt.show()
【问题讨论】:
-
你有任何你想要实现的情节的例子吗?您是否正在寻找像 this example 这样的极坐标图?
标签: matplotlib histogram