how to add legends in plt code example Example: position of legend matplotlib plt.legend(loc='upper right')