Skip to content

Empty categories are not shown if proceed existing categories #635

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

Closed
h-spiess opened this issue Mar 31, 2025 · 3 comments · Fixed by #636
Closed

Empty categories are not shown if proceed existing categories #635

h-spiess opened this issue Mar 31, 2025 · 3 comments · Fixed by #636

Comments

@h-spiess
Copy link

h-spiess commented Mar 31, 2025

Bug description

categories can be passed to scales to show empty categories too. This usually works. However, if the empty categories come before the existing categories in the passed list it does not work.

Steps to reproduce

using AlgebraOfGraphics
using CairoMakie

spec = data((; group = ["B", "C", "D"], value = [1, 3, 4])) *
    mapping(:group, :value) * visual(BarPlot)

fig = Figure()

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

Images

Image

Version info

Julia Version 1.11.3
Commit d63adeda50d (2025-01-21 19:42 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 8 default, 0 interactive, 4 GC (on 8 virtual cores)
Environment:
  JULIA_REVISE_WORKER_ONLY = 1
Status `~/Documents/PhD/NI/Lehre_PPR/Exam_Summary/Project.toml`
  [cbdf2221] AlgebraOfGraphics v0.10.0
  [336ed68f] CSV v0.10.15
  [13f3f980] CairoMakie v0.13.2
  [a93c6f00] DataFrames v1.7.0
⌃ [7f904dfe] PlutoUI v0.7.61
  [37e2e46d] LinearAlgebra v1.11.0
Info Packages marked with ⌃ have new versions available and may be upgradable.```
@jkrumbiegel
Copy link
Member

The problem here is that Makie sets the limits more tightly than you want, not that the categories themselves don't exist in the ticks. I've been wondering if AlgebraOfGraphics should enforce a minimal range of limits for categorical scales for that reason. Maybe this could be done by adding an invisible plot there.

@h-spiess
Copy link
Author

Thanks for the fast answer. Unfortunately. I'm not that familiar with AlgebraOfGraphics or Makie yet. What would the easy fix look like?

@h-spiess
Copy link
Author

h-spiess commented Mar 31, 2025

Okay, I just adjusted the lower limit of CairoMakie.xlims! to 0. However, I think this should happen automatically when categories are passed. Would be a great addition for the future.

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 a pull request may close this issue.

2 participants