Recent hotfix made `sns.relplot` incompatible with latex plotting.
See original GitHub issueHi, and first of all thanks for the great library!
I have discovered a problem with a recent hotfix (this line) and latex plotting.
Concretely, the hotfix prepends underscores to all plot variables, e.g. turning x
into_x
and only changes the labels later.
This causes a problem with the FacetGrid underlying relplot, which calls tight_layout
here.
For some reason, this causes matplotlib to render the plot with the axis labels including underscores. I believe it happens to find margins, but I am not sure. In any case, the latex render cannot handle the underscores and crashes.
Affected versions
0.11.2
only; version 0.11.1
(without the hotfix) works fine.
Steps to reproduce
import seaborn as sns
import matplotlib as mpl
import pandas as pd
mpl.rcParams.update({
'text.usetex': True,
})
testdata = pd.DataFrame({'x': [1, 2], 'y': [2, 3]})
sns.relplot(data=testdata, x='x', y='y');
This raises:
RuntimeError: latex was not able to process the following string:
b'_x'
Possible fixes
Prepend with something more latex friendly instead of underscores, e.g. temp
or anything.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Recent hotfix made `sns.relplot` incompatible with latex plotting.
I have discovered a problem with a recent hotfix (this line) and latex plotting. Concretely, the hotfix prepends underscores to all plot variables,...
Read more >seaborn.relplot — seaborn 0.12.1 documentation - PyData |
After plotting, the FacetGrid with the plot is returned and can be used directly to tweak supporting plot details or add other layers....
Read more >Plotting densities with seaborn and latex error - Stack Overflow
The issue is python is not finding latex and kpsewhich files. I resolved the issue by performing the following steps on a Mac...
Read more >seaborn lineplot add markers - BeYu Wellness
I have a set of points, and I want to draw a line plot connecting all of them. Seaborn is a highly efficient...
Read more >matplotlib.pyplot.style.context Example - Program Talk
aljpy.plot.percent_axis(ax, axis='y') ax.set_title('win rate is a sigmoid in rating ... dpi=150, bbox_inches='tight') plt.close() return f"Line plot created ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe this was handled upstream: https://github.com/matplotlib/matplotlib/pull/20706
Great news! I can confirm that it works for me again as well with matplotlib version 3.5.1 and seaborn version 0.11.2. Thanks for checking up on this.