- Matplotlib 3.0 Cookbook
- Srinivasa Rao Poladi
- 73字
- 2021-08-13 15:16:12
There's more...
One more very common option to use the legend is with loc argument on plt.legend(). This argument can take the codes 0 to 10 to specify different locations on the plot. Each of them also has a text description, which can be found on the Matplotlib documentation (https://matplotlib.org/api/legend_api.html?highlight=legend#module-matplotlib.legend).
The following is the sample code for two of the possible options:
plt.legend(loc='best') or plt.legend(loc=0)
plt.legend(loc=‘upper right’) or plt.legend(loc=1)