matplotlib极坐标图设置左侧y轴标签
我想在极坐标图的左侧写上y轴标签,就像在普通坐标图中那样。以下是我的代码:
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()
我得到的结果是这样的:

但是,我不喜欢图中间的P_y,我想把它移回左侧,就像这样:
我只想把y轴标签放到左侧,其他关于这两张图的细节可以忽略。我尝试使用:
axes.set_ylabel("$P_y$",position=(0,0.5),transform=axes.transAxes)
但没有效果。
谢谢
1 个回答
2
在极坐标图中,标签的位置是由 axes.yaxis.labelpad
这个属性来控制的。你可以把它设置成一个正数,比如说120,这样就可以把标签往左移动。