问题
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:
![](https://www.eimg.top/images/2020/03/21/09f14aa12df3ae96117988bdf2b087a8.jpg)
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:
![](https://www.eimg.top/images/2020/03/21/c11b1368439847f8fd85070cec806720.jpg)
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://www.eimg.top/images/2020/03/21/f49456d6974d0f3695674301f5ab3d77.png)
来源:https://stackoverflow.com/questions/23415277/matplotlib-polar-plot-set-ylabel-on-the-left-hand-side