You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question about working other plotting packages like seaborn. #792
Many other packages provide numerous supplements for Matplotlib. Occasionally, I need a feature that Ultraplot lacks. For instance, I miss useful statistical methods and finely tuned color themes of seaborn. I learned about ax.external(), so I gave it a try. Let's look at an example:
# %% import seaborn and prepare data
import seaborn as sns
x = np.random.randn(1000)+3
df = pd.DataFrame(x, columns=["Test Values"])
# %% plot with only seaborn and move legend
# legend was moved successfully
ax = sns.histplot(df, kde=True, legend=True)
sns.move_legend(ax, "upper left")
# %% plot with ultraplot and seaborn
# legend cannot be moved.
fig, ax = pplt.subplot()
with ax.external():
sns.histplot(df, ax=ax, kde=True, legend=True)
sns.move_legend(ax, "upper right")
I understand that working with other packages isn't really Ultraplot's agenda, and cooperation isn't always straightforward. I was also surprised to find that I can't control the legend position in Seaborn's histplot with some kind of loc argument—perhaps I missed something. Are there other ways to integrate Seaborn with Ultraplot that I'm unaware of?
Maybe we could consider adding some useful statistical fitting methods directly into Ultraplot?
While I generally cannot guarantee compatibility across all packages, I am sympathetic to just making it work. I think for this in particular, we can make it work by adding this method to our legend.
Activity
cvanelteren commentedon Aug 13, 2026
One thing you could do in this particular example is use
ax.legendinsteadWhile I generally cannot guarantee compatibility across all packages, I am sympathetic to just making it work. I think for this in particular, we can make it work by adding this method to our legend.