python - 为什么即使使用紧凑的布局,legend 和 ylabel 也会显示轴刻度?
问题描述
我使用 plt.tight_layout 创建了一个图表,但标签和图例覆盖了我的轴。为什么?
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()
在这里你可以找到我的实际情况: https ://docdro.id/asLjp4D
解决方案
推荐阅读
- python - ProgrammingError 1064 在 Python 中使用 MySQL 从现有表中执行 CREATE TABLE AS SELECT
- c++ - 是否可以使用前缀表示法调用 << 运算符?
- python - Jupyter 笔记本 - 无法安装
- css - 将 CSS 编辑为 ngb-datepicker (Angular)
- 3d - 3D人脸输入的格式是什么?
- swift - ARKit – 如何将 ARImageTrackingConfiguration 与 ARFaceTrackingConfiguration 结合使用?
- python - Python函数在调用时不返回reuslt,没有输出。我究竟做错了什么
- c# - 如何从 ac# 数组中的第二项切片元素?
- c++ - 实例化变量模板时要考虑代码的哪一部分?
- xcode - 故事板视图中文档大纲过滤器的 Xcode 快捷方式是什么?