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

Compute pagination after applying scales #593

Merged
merged 15 commits into from
Jan 30, 2025
Merged

Conversation

jkrumbiegel
Copy link
Member

@jkrumbiegel jkrumbiegel commented Jan 28, 2025

This PR changes the pagination mechanism. Before, layers were converted to processed layers, and those were then split apart based on their input data. The problem with that approach was that it made each page independent of the others. This can be seen in this MWE:

df = (x = 1:4, y = 1:4, page = [1, 1, 2, 2], color = ["A", "B", "C", "D"])
spec = data(df) *
    mapping(:x, :y, color = :color, layout = :page => nonnumeric) *
    visual(Scatter, markersize = 30)
draw(spec)
image

When we split this into two pages, we get this on master:

p = paginate(spec, layout = 1)
draw(p, 2)
image image

Both A & C and B & D share the same color in the legend because each page has separately computed categorical scales. (This problem does not appear if all pages have the same categories, but that's not something to generally rely on.)

With this PR, the pages reflect the original colors from the full plot, and the legend also lists all categories on both pages.

image image

In case there are lots of categories that crowd the legend, it might be possible in the future to remove the legend entries for categories that don't appear on a given page, while still keeping the overall colorscheme intact.

@jkrumbiegel jkrumbiegel changed the title Allow pagination to use scales Allow paginate to use scales Jan 28, 2025
@jkrumbiegel jkrumbiegel marked this pull request as ready for review January 29, 2025 16:31
@jkrumbiegel jkrumbiegel changed the title Allow paginate to use scales Compute pagination after applying scales Jan 30, 2025
@jkrumbiegel jkrumbiegel merged commit 98a216b into master Jan 30, 2025
5 checks passed
@jkrumbiegel jkrumbiegel deleted the jk/pagination-and-scales branch January 30, 2025 09:33
@jkrumbiegel jkrumbiegel mentioned this pull request Jan 30, 2025
jkrumbiegel added a commit that referenced this pull request Jan 30, 2025
- **Compute pagination after applying scales (#593)**
- **Bump to 0.9.0**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant