I add some information in a Python plot (with import matplotlib.pyplot as plt
), using this code:
plt.text(0.0, 20000.0, r'$[R^2 = %s]$'% (round(R2,4)), fontsize=16)
plt.text(0.0, 22500.0, r'$[y = %s x]$'% (round(slope[0][0],4)), fontsize=16)
The values inserted in the plot, R2
and slope[0][0]
have been previously calculated.
This works perfectly fine, but in order to insert the 2 values of R2
and slope
at different places, I need 2 calls of plt.text
.
I wonder whether it would be possible to use just 1 call? I guess I would have to add \n
somewhere in order to have the 2 texts aligned one below the other, but I don't understand the right syntax to use.
Any ideas?