Skip to content

Commit

Permalink
Setup automatic colorbars for volumeslices
Browse files Browse the repository at this point in the history
  • Loading branch information
ffevotte committed Sep 25, 2023
1 parent 2eda281 commit bf2dbfa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ReferenceTests/src/tests/figures_and_makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ end

# TO not make this fail in CairoMakie, we dont actually plot the volume
_f, ax, cp = contour(x, y, z, values; levels=10, colormap=:viridis)
Colorbar(fig[2, :], cp; size=300)
Colorbar(fig[2, 1], cp; size=300)

_f, ax, vs = volumeslices(x, y, z, values, colormap=:bluesreds)
Colorbar(fig[2, 2], vs)

# horizontal colorbars
Colorbar(fig[1, 3][2, 1]; limits=(0, 10), colormap=:viridis,
Expand Down
4 changes: 4 additions & 0 deletions src/makielayout/blocks/colorbar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ function extract_colormap(plot::StreamPlot)
return extract_colormap(plot.plots[1])
end

function extract_colormap(plot::Combined{volumeslices})
return extract_colormap(plot.plots[1])
end

function extract_colormap(plot::Union{Contourf,Tricontourf})
levels = plot._computed_levels
limits = lift(l -> (l[1], l[end]), levels)
Expand Down

0 comments on commit bf2dbfa

Please sign in to comment.