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

colormap not applied #530

Closed
RomeoV opened this issue Aug 24, 2024 · 2 comments · Fixed by #531
Closed

colormap not applied #530

RomeoV opened this issue Aug 24, 2024 · 2 comments · Fixed by #531

Comments

@RomeoV
Copy link

RomeoV commented Aug 24, 2024

Bug description & steps to reproduce

The colormap kwarg currently doesn't seem to be applied at all.
E.g. after some setup...

versioninfo()  # Julia Version 1.10.4
import Pkg; Pkg.activate(temp=true)
Pkg.add(["GLMakie", "AlgebraOfGraphics"])
using GLMakie, AlgebraOfGraphics
df = (x=rand(100), y=rand(100), z=rand(100))
plt = data(df) * mapping(:x, :y, color=:z)

...then choosing a different colormap with visual(..., colormap=:thermal) should change the colors.

plt * visual(Scatter) |> draw
# vs 
plt * visual(Scatter, colormap=:thermal) |> draw

However, instead they produce the same picture (see below).
This also applies to other colormaps.

Note that with just Makie it works fine, i.e. the pictures are different:

scatter(df.x, df.y, color=df.z)
scatter(df.x, df.y, color=df.z, colormap=:thermal)

Images

Using AlgebraOfGraphics:

fig = Figure();
draw!(fig[1, 1], plt * visual(Scatter), axis=(; title="`colormap=:default`"));
draw!(fig[1, 2], plt * visual(Scatter, colormap=:thermal), axis=(; title="`colormap=:thermal`"));
save("aog.png", fig)

aog

Using just Makie:

fig = Figure();
scatter(fig[1, 1], df.x, df.y, color=df.z, axis=(; title="`colormap=:default`"));
scatter(fig[1, 2], df.x, df.y, color=df.z, colormap=:thermal, axis=(; title="`colormap=:thermal`"));
save("makie.png", fig)

makie

Version info

Please include the output of versioninfo() and Pkg.status() for the environment
where the issue occurred.

julia> versioninfo()
Julia Version 1.10.4
Commit 48d4fd48430 (2024-06-04 10:41 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × 11th Gen Intel(R) Core(TM) i7-11800H @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 1 default, 0 interactive, 1 GC (on 16 virtual cores)
Environment:
  JULIA_ERROR_COLOR = red

julia> Pkg.status()
Status `/tmp/jl_jkrCb0/Project.toml`
  [cbdf2221] AlgebraOfGraphics v0.8.3
  [e9467ef8] GLMakie v0.10.7
@RomeoV
Copy link
Author

RomeoV commented Aug 25, 2024

For others running into this issue, I've found that you can work with the colormap by using scales, e.g. as in https://aog.makie.org/dev/layers/draw/#Color.

Probably the example in https://aog.makie.org/dev/gallery/gallery/customization/colorbar/#Colorbar-tweaking needs to be modified, as this is where I got the syntax from in the first place.

@jkrumbiegel
Copy link
Member

You do this via scales now so that there's a single point to change for a given color scale. Otherwise things would get confusing if you layer multiple plots that share a color scale, but you modify them separately via visual. The continuous color is shown here https://aog.makie.org/stable/layers/draw/#Color-2

RomeoV added a commit to RomeoV/AlgebraOfGraphics.jl that referenced this issue Aug 25, 2024
Now we have to pass the colormap to `scales` instead of to `mapping` as before.

Closes MakieOrg#530.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants