Skip to content

Saving images corrupts x and y tick labels #3153

Description

@mattharrison

I'm trying to create some Seaborn plots for an upcoming book and the x/y tick values are getting corrupted when saving it as a PNG.

Using version 0.12.1.

# bug in seaborn objects matplotlib saving
import matplotlib.pyplot as plt
import pandas as pd
import seaborn.objects as so
url = 'https://raw.githubusercontent.com/vincentarelbundock/Rdatasets/master/csv/DAAG/possum.csv'

df = pd.read_csv(url, index_col=[0])
fig, ax = plt.subplots(figsize=(6,4))
(so
 .Plot(df, x='age', y='skullw', color='sex')
 .add(so.Dots())
 .on(fig)
 .plot()
)
fig.savefig('/tmp/so.png', dpi=600, bbox_inches='tight')

The result looks like this:
so

However, if I remove the saving logic....

(so
 .Plot(df, x='age', y='skullw', color='sex')
 .add(so.Dots())
)

The plot looks like this:

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions