Matplotlib 图例未对齐

时间:2021-02-17 21:51:51

标签: matplotlib legend

enter image description here

我正在尝试在 Matplotlib 中绘制图例,但由于某种原因,标签与线条描述不一致。你知道为什么会这样吗?代码如下:

gs = gridspec.GridSpec(2, 2)

fig=plt.figure(facecolor='white',figsize=sizefigs_L)

ax=fig.add_subplot(gs[0, 0])
ax=settings_plot(ax)

lm_space=[x for x in l_space]
lt_space=[tilde_l(x,L,df[0],A,xi) for x in l_space]

plt.plot(l_space,lm_space,ls='--',c='r',label=r'$\lambda_m$')
plt.plot(l_space,lt_space,ls='-',c='b',label=r'$\tilde{\lambda}$')

plt.scatter(L-xi,L-xi,marker='o',c='g',s=200)
plt.scatter(L+xi,L+xi,marker='o',c='g',s=200)

plt.scatter(lsol(L,df[0],A)[1],lsol(L,df[0],A)[1],marker='s',c='m',s=200)

plt.arrow(lsol(L,df[0],A)[1], lsol(L,df[0],A)[1]+0.15, 0.10, 0.075, width=0.005,head_width=0.03,
         fc='k', ec='k',length_includes_head=True)
plt.arrow(lsol(L,df[0],A)[1]-0.05, lsol(L,df[0],A)[1]+0.1, -0.10, -0.075, width=0.005,head_width=0.03,
         fc='k', ec='k',length_includes_head=True)


plt.legend(loc='best',frameon=False,fontsize=16)
plt.xlabel(r'Expectation of marginal investor ($\lambda_m$)',fontsize=16)
plt.ylabel(r'Reaction function $\tilde{\lambda}\left(\lambda_m\right)$',fontsize=16)

plt.title(r'Case (i): $\Delta f \leq \zeta \left(\Lambda-\xi\right)\xi$',fontsize=16)```

0 个答案:

没有答案
相关问题