Skip to content

Question about working other plotting packages like seaborn. #792

Closed

Description

@gepcel

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?

Activity

  1. cvanelteren commented on Aug 13, 2026

    @cvanelteren
    Collaborator

    One thing you could do in this particular example is use ax.legend instead

    fig, ax = uplt.subplot()
    with ax.external():
        sns.histplot(df, ax=ax, kde=True, legend=False)
    
    # sns.move_legend(ax, "upper right")
    ax.legend(loc = "ll")
    
    

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions