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

When multiple categories are plotted, only one legend is shown, and colors do not match #364

Open
2 tasks
LucaMarconato opened this issue Sep 27, 2024 · 3 comments
Labels
bug Something isn't working enhancement New feature or request labels 🏷️ Anything related to Labels priority: medium

Comments

@LucaMarconato
Copy link
Member

Plotting a single categorical variable works great. This code plots two categorical variables together.

Problems:

  • The legend gets mixed; I would consider adding two legends.
  • The plot shows 4 different colors, while the legend shows 2. I think the legend is correct and the plot is wrong.
from spatialdata.datasets import blobs
import spatialdata_plot
import matplotlib.pyplot as plt
from numpy.random import default_rng

RNG = default_rng(0)

sdata = blobs()
sdata['table'].obs['cat0'] = RNG.choice(['A', 'B'], size=len(sdata['table']))
sdata['table'].obs['cat0'] = sdata['table'].obs['cat0'].astype('category')
sdata['table'].obs['cat1'] = RNG.choice(['C', 'D'], size=len(sdata['table']))
sdata['table'].obs['cat1'] = sdata['table'].obs['cat1'].astype('category')

(
    sdata
    .pl.render_labels("blobs_labels", color='cat0')
    .pl.render_labels("blobs_labels", color='cat1')
    .pl.show()
)

plt.show()

image

@LucaMarconato LucaMarconato added the bug Something isn't working label Sep 27, 2024
@timtreis
Copy link
Member

How does it look like if you create an ax and then push two separate calls onto it?

@LucaMarconato
Copy link
Member Author

LucaMarconato commented Sep 27, 2024

The same plot is produced.

@timtreis
Copy link
Member

hm, meh. Yeah, the legends/colorbars for two plots on the same axis are lacking

@timtreis timtreis added enhancement New feature or request labels 🏷️ Anything related to Labels priority: medium labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request labels 🏷️ Anything related to Labels priority: medium
Projects
None yet
Development

No branches or pull requests

2 participants