Python matplotlib:同一图例中的不同handletextpad值

Python matplotlib:同一图例中的不同handletextpad值,python,matplotlib,Python,Matplotlib,我有以下脚本: fig = plt.figure() fig.set_size_inches(8,7) ax1 = fig.add_subplot(1,1,1) ### PLOT for k in my_dict: x, y = my_dict[k][0], my_dict[k][1] ax1.plot(x, y, linewidth = 0, marker='o', markersize = 4) X = np.logspace(0.3, 6.6) ax1.plo

我有以下脚本:

fig = plt.figure()
fig.set_size_inches(8,7)

ax1 = fig.add_subplot(1,1,1)


### PLOT

for k in my_dict:

    x, y = my_dict[k][0], my_dict[k][1]
    ax1.plot(x, y, linewidth = 0, marker='o', markersize = 4)


X = np.logspace(0.3, 6.6)
ax1.plot(X, 2*X**(-2), linewidth = 2, c='k')

X = np.logspace(0.3, 7.7)
ax1.plot(X, 3*X**(-1.5), linewidth = 2, c='b')


ax1.set_xscale('log')
ax1.set_yscale('log')


## LEGEND


labels = ['$10^{-1} \, \\Delta_1^*$', '$\\Delta_1^*$',\
          '$10^{5/2} \, \\Delta_1^*$', '$10^3 \, \\Delta_1^*$',
         '$x^{-2}$', '$x^{-3/2}$']

curves = ax1.get_lines()
legend1 = ax1.legend([curves[0], curves[1], curves[2]],\
                     [labels[0], labels[1], labels[2]],\
                     loc=1, ncol=1, fancybox=False, shadow=False,\
                     framealpha=0.0, markerscale=2, fontsize=25, handletextpad=0.0)

legend2 = ax1.legend([curves[3], curves[4], curves[5]],\
                     [labels[3], labels[4], labels[5]],\
                     loc=3, ncol=1, fancybox=False, shadow=False,\
                     framealpha=0.0, markerscale=2, fontsize=25, handletextpad=0.0)




vp = legend1._legend_box._children[-1]._children[0]
for c in vp._children:
    c._children.reverse()
vp.align="right"


ax1.add_artist(legend1)
ax1.add_artist(legend2)


fig.tight_layout()
plt.show()

结果是

问题:我在图例中使用了
handletextpad
,这是因为我需要点和文本非常接近。但是,第二个图例中的最后两个元素不是点,而是线。它们比点占用更多的空间,而且文本恰好太近

我需要保持文本和点之间的距离,同时增加同一图例中文本和线之间的距离

我尝试了
handletextpad=[0.1,0.5,0.5]
和类似的策略,但我无法设置
handletextpad
的单个值

另一种可能是制作单独的图例,特别是只有线条的图例。然而,这将迫使我非常小心地手动定位任何图例,我宁愿不这样做。还有(我不知道是否有帮助),但我不想更换

plt.plot(x,y,线宽=0,标记大小=4)

plt.scatter(x,y)

除了这两个警告,一切都是受欢迎的