Global matplotlib style with objects interface #3005
-
Hey! thanks for the amazing 0.12 release 🚀 ! I want to use the new object interface while using a global I have tried: import matplotlib.pyplot as plt
import seaborn as sns
import seaborn.objects as so
anscombe = sns.load_dataset("anscombe")
plt.style.use("bmh")
sns.set_theme({**style.library["bmh"]})
sns.set_style({**style.library["bmh"]})
sns.set_theme(rc=style.library["bmh"])
sns.set_style(rc=style.library["bmh"])
p = (
so.Plot(anscombe, "x", "y")
.facet("dataset", wrap=2)
.add(so.Line(), so.PolyFit(order=1))
.add(so.Dot())
)
p but I am still getting: Any tips on how to make this work? Thanks! Remark: With the "old" seaborn's functional API it works as expected. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
There is some context in the PR: #2929 One of the design principles in the (
so.Plot(anscombe, "x", "y")
.facet("dataset", wrap=2)
.add(so.Line(), so.PolyFit(order=1))
.add(so.Dot())
.theme(plt.style.library["bmh"])
) |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for the explanation! 😊 I'll keep exploring the new object API 🚀 |
Beta Was this translation helpful? Give feedback.
-
FYI in my case to "propagate" the global style changes: import seaborn as sns
import seaborn.objects as so
import matplotlib.pyplot as plt
my_palette = ...
sns.set_theme(style="whitegrid", palette=my_palette)
plt.rc("figure", figsize=(16, 4), dpi=150) To the Plot API, I had to: (
so.Plot(...)
.scale(color=sns.color_palette())
.theme(plt.rcParams)
) I'm not entirely sure that's optimal/best solution, would appreciate input if there's a better way. Also looking forward to defaults in Objects API 🤞 |
Beta Was this translation helpful? Give feedback.
-
See #3223 |
Beta Was this translation helpful? Give feedback.
See #3223