matplotlib tight_layout legend outside code example Example: matplotlib savefig legend cut off fig.savefig('figure.png', bbox_inches='tight')