matplotlib polar plot set_ylabel on the left hand side

随声附和 提交于 2019-12-13 01:23:34

问题


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:

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:

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)

But do not help.

Thank you


回答1:


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



来源:https://stackoverflow.com/questions/23415277/matplotlib-polar-plot-set-ylabel-on-the-left-hand-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!