matplotlib的标准间隔为45°。 如何将间隔改为15°? 所以我从下面的图片开始
到这个图像
问题是我找不到合适的文件。 这是当前使用的代码:
#Define arrays
def processDir(file, output, title):
angles=list()
values=list()
lines = [line.rstrip('\n') for line in open(file)]
for line in lines: # Iterate lines
stringElement = str.split(line, " ") # Split elements
angle = int(stringElement[0])
value = float(stringElement[1])
angles.append((angle/360)*2*3.1415926)
values.append(value)
ax = plt.subplot(111, projection='polar')
plt.polar(angles, values, label=title, color="darkviolet")
ax.legend(bbox_to_anchor=(0., 1.1, -1., .102), loc=3,
ncol=2, mode="expand", borderaxespad=0., frameon=False)
ax.grid(True)
axmin = ax.get_rmin()
axmax = ax.get_rmax()
#Zorg ervoor dat de stap 6dB per lijn is
step = 6
# generate new ticklist with desired step size
axlist = np.arange(axmin, axmax + step, step)
# set new ticks
ax.set_rticks(axlist)
ax.figure.set_size_inches(8, 5)
plt.savefig(output)
plt.show()
processDir("test.txt", "no output", "My Title")
使用文本文件:
0 54.3
15 54.4
30 54.2
45 54.2
60 54.4
75 54.8
90 55.6
120 56.3
150 57.5
180 57
210 56.8
240 56.8
270 57.4
300 57.1
330 57.2
360 54.3
您应该始终提供Minimal, Complete, and Verifiable example,否则问题可能会被搁置。
幸运的是,我记得your previous question。也可以在极坐标图中调整x记号。使用以前的示例代码:
回顾你以前的问题,你同样可以解决你以前的问题:
如果我们也将其整合,输出结果将是:
相关问题 更多 >
编程相关推荐