Closed simonmarti1992 closed 7 months ago
I haven't done any testing, but cmon, what you are feeding into Matplotlib is the LaTeX you want to render. How do you insert a line break in LaTeX?
https://www.overleaf.com/learn/latex/Line_breaks_and_blank_spaces#Line_breaks
Feel free to close when resolved.
Thank you for your feedback, but it doesn't answer my question. The error was due to improper use of the 'r' at the beginning of the string. Here's an example that works
import scienceplots
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use(['science','no-latex','grid'])
iris = sns.load_dataset('iris')
iris.head()
fig, (ax) = plt.subplots(1,1, figsize = (15,5))
ax.plot(iris.index, iris.sepal_length)
ax.set_ylabel('my \n test')
And here is the case that is not wordking properly
import scienceplots
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use(['science','no-latex','grid'])
iris = sns.load_dataset('iris')
iris.head()
fig, (ax) = plt.subplots(1,1, figsize = (15,5))
ax.plot(iris.index, iris.sepal_length)
ax.set_ylabel(r'my \n test')
Thanks for reporting the solution.
When I use the package, I can no longer write texts with accents and line breaks in my y-labels
I tried several common tricks for strings in y-labels like ax.set_ylabel(r"MyTest"), but it didn't work