Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dual axis plot broken in 0.13.2 (vs. 0.12.2) #3745

Open
divingtobi opened this issue Aug 7, 2024 · 2 comments
Open

Dual axis plot broken in 0.13.2 (vs. 0.12.2) #3745

divingtobi opened this issue Aug 7, 2024 · 2 comments

Comments

@divingtobi
Copy link

divingtobi commented Aug 7, 2024

The following code produces a dual axis plot with properly labelled tick marks on both axis with seaborn 0.12.2 (python 3.10.11). However, with seaborn 0.13.2 (python 3.11.4) the tick labels of the right axis are duplicated on the left axis.

import seaborn.objects as so
import pandas as pd
import matplotlib.pyplot as plt


df = pd.DataFrame(
    {"x": [1, 2, 3, 4, 5], "y1": [5, 2, 1, 6, 2], "y2": [1000, 240, 1300, 570, 120]}
)
fig, ax1 = plt.subplots(1, 1, figsize=(6, 4))
ax2 = ax1.twinx()
ax1.tick_params(axis="x", labelrotation=45)
p1 = (
    so.Plot(df, x="x", y="y1")
    .add(so.Bar(width=0.7))
    .label(x="Month", y="Data 1", title="TITLE")
    .on(ax1)
    .plot()
)
p2 = (
    so.Plot(df, x="x", y="y2")
    .add(so.Line(color="orange", linewidth=3))
    .label(y="Data 2", title="TITLE")
    .scale(y=so.Continuous().label(like="{x:,.0f}"))
    .on(ax2)
    .plot()
)

Result with 0.13.2:
image

Result with 0.12.2:
image

@mwaskom
Copy link
Owner

mwaskom commented Aug 7, 2024

Are you holding the matplotlib version constant here?

@MaozGelbart
Copy link
Contributor

Looks like a duplicate of #3614. Can confirm the issue here is fixed by #3696.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants