-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
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()
)
Metadata
Metadata
Assignees
Labels
No labels