matplotlib极坐标图set_ylabel在左侧 [英] matplotlib polar plot set_ylabel on the left hand side

查看:453
本文介绍了matplotlib极坐标图set_ylabel在左侧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将ylabel写在极坐标图中的左侧,就像在非极坐标图中那样.这是我的代码:

I want to write the ylabel on the left hand side in polar plot as that in the non-polar plot. Here is my code:

import matplotlib.pyplot
axes=matplotlib.pyplot.figure().add_subplot(1,1,1,polar=True,frameon=False)
import numpy
x=numpy.linspace(0,12*numpy.pi,2000)
axes.plot(x,numpy.exp(numpy.cos(x))-2*numpy.cos(4*x)+numpy.sin(x/12)**5,color="black")
axes.set_xlabel("y")
axes.set_ylabel("$P_y$")
axes.set_xticklabels([])
axes.set_yticklabels([])
axes.grid(False)
import matplotlib.backends.backend_pdf
output=matplotlib.backends.backend_pdf.PdfPages("butterfly.pdf")
output.savefig()
output.close()

我得到这样的结果:

And I get the result like this:

但是,我不喜欢图片中间的P_y,我希望它回到左侧,就像这样:

However, I do not like the P_y at the middle of picture, I want it go back to the left hand side, just like this:

我只想将ylabel更改为左侧,关于这两个图片的区别的其他细节可以忽略.我尝试使用:

I just want to change ylabel to the left hand side, other detail about the difference of such two picture can be ignore. I try to use:

axes.set_ylabel("$P_y$",position=(0,0.5),transform=axes.transAxes)

但是没有帮助.

谢谢

推荐答案

它由极坐标图中的axes.yaxis.labelpad属性控制.您可以将其设置为正数,以将标签向左移动,例如120

It is controlled by axes.yaxis.labelpad property in a polar plot. You can set it to positive number to mover the label to the left, say 120

这篇关于matplotlib极坐标图set_ylabel在左侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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