1. 使用 plt.savefig() 时图例在图像外面,直接保存会导致图例只保存部分。
PIL.savefit('name',dpi=1200,bbox_inches = 'tight')
加入bbox_inches='tight'之后就可以保存图像外的图例
2.绘制双纵轴坐标图 :
参考文献:https://www.cnblogs.com/dajunma21/p/9001145.html
%matplotlib inline
from mpl_toolkits.axisartist.parasite_axes import HostAxes, ParasiteAxes
import matplotlib.pyplot as plt
fig = plt.figure(1)
#HostAxes(figure,[ 左,下,宽,高 ])
host = HostAxes(fig, [0.15, 0.1, 0.65, 0.8])
#增加纵坐标轴,sharex代表共享x轴
par1 = ParasiteAxes(host, sharex=host)
#添加轴
host.parasites.append(par1)
#隐藏上方坐标轴
host.axis['top'].set_visible(False)
#坐标轴名字
host.set_ylabel('Denstity')
host.set_xlabel('Distance')
#隐藏右方坐标轴
host.axis['right'].set_visible(False)
par1.axis['right'].set_visible(True)