Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么legend和ylabel即使使用紧凑布局也会显示盖轴刻度?_Python_Plot - Fatal编程技术网

Python 为什么legend和ylabel即使使用紧凑布局也会显示盖轴刻度?

Python 为什么legend和ylabel即使使用紧凑布局也会显示盖轴刻度?,python,plot,Python,Plot,我使用plt.tight_布局创建了一个图表,但标签和图例覆盖了我的轴。为什么? fig7 = plt.figure(figsize=(19/2.54,10/2.54)) ax1 = fig7.add_subplot(1,1,1) ax1.scatter(S1_daily.loc[S1_daily['Work Type'] !='DHW', 'Date'],S1_daily.loc[S1_daily['Work Type'] !='DHW', 'eta daily (PCS)'], color=

我使用plt.tight_布局创建了一个图表,但标签和图例覆盖了我的轴。为什么?

fig7 = plt.figure(figsize=(19/2.54,10/2.54))
ax1 = fig7.add_subplot(1,1,1)
ax1.scatter(S1_daily.loc[S1_daily['Work Type'] !='DHW', 'Date'],S1_daily.loc[S1_daily['Work Type'] !='DHW', 'eta daily (PCS)'], color='k',s=9, label='\u03B7_day (SH & DHW)')
ax1.scatter(S1_daily.loc[S1_daily['Work Type'] =='DHW', 'Date'],S1_daily.loc[S1_daily['Work Type'] =='DHW', 'eta daily (PCS)'], facecolors='none', edgecolors='k',s=11, label='\u03B7_day (Only DHW)')
ax1.set_ylabel('\u03B7_day (-)')
ax2 = ax1.twinx()
ax2.scatter(S1_daily.loc[S1_daily['Work Type'] !='DHW', 'Date'],S1_daily.loc[S1_daily['Work Type'] !='DHW', 'Qmean gas allday(kW)'], marker='^', color='r',s=9, label='Qgas_day (SH & DHW)')
ax2.scatter(S1_daily.loc[S1_daily['Work Type'] =='DHW', 'Date'],S1_daily.loc[S1_daily['Work Type'] =='DHW', 'Qmean gas allday(kW)'], marker='^', facecolors='none', edgecolors='r',s=11, label='Qgas_day (Only DHW)')
plt.gcf().subplots_adjust(right=1.08)
ax2.set_ylabel('Qgas_day (kW)', rotation=270)
fig7.legend(loc='lower center', bbox_to_anchor=(0.5, -0.007),ncol=2, fontsize=7)
plt.tight_layout()


在这里你可以找到我的实际情况:

您好,我不确定是否正确理解您,这是正常行为=>您的图例“附加”在您给它的坐标上,并且仍然在图的框架内。所以紧凑的布局不会改变任何事情。你能解释一下你想要达到的预期产量吗?“紧密布局自动调整子地块参数,使子地块适合图形区域。这是一项实验性功能,在某些情况下可能不起作用。它只检查标签、轴标签和标题的范围。”[好的,我理解你对图例的看法,以及第二个ylabel的看法。我是说'Qgas_day(kW)]'不应包含y轴的值,但它包含y轴,我不知道如何移动它,我再次尝试使用bbox_to_锚定,但它不起作用。我不确定是否正确理解您,这是正常行为=>您的图例已“附加”到你给它的坐标,并且仍然在图的框架内。所以紧密布局不会改变任何东西。你能解释一下你想要达到的预期输出吗?“紧密布局自动调整子地块参数,以便子地块适合于图形区域。这是一项实验性功能,在某些情况下可能不起作用。它只检查标签、轴标签和标题的范围。“[好的,我理解你对图例的看法,以及第二个ylabel的看法?我的意思是'Qgas_day(kW)'不应覆盖y轴的值,但它覆盖了y轴,我不知道如何移动它,我再次尝试使用bbox_to_锚定,但它不起作用