question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recent hotfix made `sns.relplot` incompatible with latex plotting.

See original GitHub issue

Hi, 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mwaskomcommented, Apr 3, 2022

I believe this was handled upstream: https://github.com/matplotlib/matplotlib/pull/20706

0reactions
NotSpecialcommented, Apr 4, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found