隐藏径向刻度标签 matplotlib [英] Hide radial tick labels matplotlib

查看:62
本文介绍了隐藏径向刻度标签 matplotlib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码绘制极坐标图:

I'm trying to plot a polar plot with this code:

import numpy as np
import matplotlib.pylab as plt
def power(angle, l, lam):
    return 1/(lam) * ((np.cos(np.pi*l*np.cos(angle)/lam) - np.cos(np.pi*l/lam))/np.sin(angle))**2
fig = plt.figure(1)
ax = fig.add_subplot(111, projection='polar')
theta = np.linspace(0.001, 2*np.pi, 100)
P1 = power(theta, 1, 5)
ax.plot(theta, P1, color='r', linewidth=3)
plt.savefig('1.png')

我得到这个情节:

我想更改2件事.第一个也是更重要的一个是隐藏径向刻度标签(我只想显示图形的一般形式).

I would like to change 2 things. The first and more important one is to hide the radial tick labels (I just want to show the general form of the plot).

如果可以,如何选择垂直轴对应0°?

If possible, how can I choose the vertical axis to correspond to 0°?

感谢您的帮助.

推荐答案

您可以使用 set_yticklabels()除去径向刻度,并使用 set_theta_zero_location()更改零地点:

You can use set_yticklabels() to remove the radial ticks and set_theta_zero_location() to change the zero location:

fig = plt.figure(1)
ax = fig.add_subplot(111, projection='polar')
ax.plot(theta, P1, color='r', linewidth=3)
ax.set_yticklabels([])
ax.set_theta_zero_location('N')
plt.show()

您可能还想更改方位轴的方向:

You might also want to change the direction of the azimuthal axis:

ax.set_theta_direction(-1)

这篇关于隐藏径向刻度标签 matplotlib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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