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

Always show all categories #636

Merged
merged 5 commits into from
Mar 31, 2025
Merged

Conversation

jkrumbiegel
Copy link
Member

Fixes #635

Before, Makie could in some cases pick limits that were too tight for a given categorical axis, for example if categories were added without data:

spec = data((; group = ["B", "C"], value = [1, 2])) *
    mapping(:group, :value) * visual(Scatter)

draw(
    spec,
    scales(
        X = (; categories = ["A", "B", "C", "D"]),
    ),
)
image

Now, invisible entries are added that keep the limits at least at first-0.5 to last+0.5, which makes sense given that each category always gets a column of width 1 centered around its position. The example above then becomes:

image

I had actually thought about doing this for a while, not necessarily because of the missing categories edge case, but because widthless plots like scatters look cramped with categorical data, as can be seen above. That normal case now looks like this, which is much more balanced:

image

Although this PR changes a lot of reference images slightly, I don't consider it breaking, because this is both a bug fix and an aesthetic improvement, where I don't expect anybody to rely on the exact auto-margin they got previously with categorical data.

@jkrumbiegel jkrumbiegel merged commit e347d1f into master Mar 31, 2025
5 checks passed
@jkrumbiegel jkrumbiegel deleted the jk/categorical-pseudo-entries branch March 31, 2025 13:44
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.

Empty categories are not shown if proceed existing categories
1 participant