'Text annotations in matplotlib on next line (linebreak) using '\n' give a square box instead of a line break
I tried to create text annotations in matplotlib using \n, on the plot instead of a line break it is showing a square box
"Fault location:" + str(sc) + "\nI_sc=" + str(fault)
I wanted to Fault location and I_sc in separate line like
Fault location: 1
I_sc=2
Solution 1:[1]
Possible solution is the following:
import matplotlib.pyplot as plt
sc = 1
fault = 2
plt.annotate(f'Fault location: {str(sc)}\nI_sc={str(fault)}', xy=(0.5, 0.5))
plt.show()
Returns
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | gremur |