Skip to content

Recent hotfix made sns.relplot incompatible with latex plotting. #2673

@NotSpecial

Description

@NotSpecial

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions