如何更改 matplotlib 极坐标图的“r"轴位置? [英] How to change the location the 'r' axis for matplotlib polar plot?

查看:82
本文介绍了如何更改 matplotlib 极坐标图的“r"轴位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改 matplotlib 极坐标图的 'r' 轴的位置?

How to change the location the 'r' axis for matplotlib polar plot?

我正在尝试更改极坐标图中r轴的位置.目前它被数据掩盖了,但是数据在theta = 340-360度时有一个间隙(在我的实际数据示例中,实际上是大约45度),所以如果我能放轴标签在数据间隙中.

I am trying to change the location of the r axis in a polar plot. At the moment it is being covered up by the data, but there is a gap in the data at theta = 340-360 degrees (in my real data example this is actually approx. 45 degrees) so it would be good if i could put axis labels there, in the data gap.

import random
import numpy as np
import matplotlib.pyplot as plt
sampleSize=1000
az=[]
inc=[]
for i in range(sampleSize):
    az.append(random.randint(0,340)) #not to the full 360 to represent my natural gap in the data
    inc.append(random.randint(0,90))

plt.figure()
plt.polar(np.radians(az),inc,'o')
plt.show()

推荐答案

我能想到的一种方法是使用 .set_rgrids 方法:

One way that I can think of is to use .set_rgrids method:

f=plt.figure()
ax = f.add_axes([0.1, 0.1, 0.8, 0.8], projection='polar')
ax.plot(np.radians(az), inc, 'o')
ax.set_rgrids([10,20,30,40,50,60,70,80,90], angle=345.)

这篇关于如何更改 matplotlib 极坐标图的“r"轴位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆