diff --git a/CHANGELOG.md b/CHANGELOG.md index c582e60..c76c7ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [unreleased] + +### Added + +- new key word argument `show_colorbar` (default=true) to toggle the color bar next to grid plots + ## [1.8.2] - 2024-11-08 ### Fixed diff --git a/src/dispatch.jl b/src/dispatch.jl index e0b6093..4b9db2f 100644 --- a/src/dispatch.jl +++ b/src/dispatch.jl @@ -351,7 +351,8 @@ function default_plot_kwargs() :dim => Pair(1, "Data dimension for PlutoVista plot"), :regions => Pair(:all, "List of regions to plot"), :species => Pair(1, "Number of species to plot or number of species in regions"), - :spacing => Pair(nothing, "Removed from API")) + :spacing => Pair(nothing, "Removed from API"), + :show_colorbar => Pair(true, "Show color bar next to grid plots")) end # diff --git a/src/makie.jl b/src/makie.jl index afa0e5e..e52c90c 100644 --- a/src/makie.jl +++ b/src/makie.jl @@ -496,28 +496,30 @@ function makescene_grid(ctx) ncol = length(ctx[:cmap]) nbcol = length(ctx[:bcmap]) # fontsize=0.5*ctx[:fontsize],ticklabelsize=0.5*ctx[:fontsize] - if ctx[:colorbar] == :vertical - GL[1, 2] = XMakie.Colorbar(ctx[:figure]; - colormap = XMakie.cgrad(ctx[:cmap]; categorical = true), - limits = (0.5, ncol+0.5), - ticks = 1:ncol, - width = 15,) - GL[1, 3] = XMakie.Colorbar(ctx[:figure]; - colormap = XMakie.cgrad(ctx[:bcmap]; categorical = true), - limits = (0.5, nbcol+0.5), - ticks = 1:nbcol, - width = 15,) - elseif ctx[:colorbar] == :horizontal - GL[2, 1] = XMakie.Colorbar(ctx[:figure]; - colormap = XMakie.cgrad(ctx[:cmap]; categorical = true), - limits = (1, ncol), - height = 15, - vertical = false,) - GL[3, 1] = XMakie.Colorbar(ctx[:figure]; - colormap = XMakie.cgrad(ctx[:bcmap]; categorical = true), - limits = (1, nbcol), - height = 15, - vertical = false,) + if ctx[:show_colorbar] + if ctx[:colorbar] == :vertical + GL[1, 2] = XMakie.Colorbar(ctx[:figure]; + colormap = XMakie.cgrad(ctx[:cmap]; categorical = true), + limits = (0.5, ncol+0.5), + ticks = 1:ncol, + width = 15,) + GL[1, 3] = XMakie.Colorbar(ctx[:figure]; + colormap = XMakie.cgrad(ctx[:bcmap]; categorical = true), + limits = (0.5, nbcol+0.5), + ticks = 1:nbcol, + width = 15,) + elseif ctx[:colorbar] == :horizontal + GL[2, 1] = XMakie.Colorbar(ctx[:figure]; + colormap = XMakie.cgrad(ctx[:cmap]; categorical = true), + limits = (1, ncol), + height = 15, + vertical = false,) + GL[3, 1] = XMakie.Colorbar(ctx[:figure]; + colormap = XMakie.cgrad(ctx[:bcmap]; categorical = true), + limits = (1, nbcol), + height = 15, + vertical = false,) + end end GL end diff --git a/src/plutovista.jl b/src/plutovista.jl index 258e9fd..1b319a3 100644 --- a/src/plutovista.jl +++ b/src/plutovista.jl @@ -253,6 +253,7 @@ function gridplot!(ctx, TP::Type{PlutoVistaType}, ::Type{Val{2}}, grid) edges = edges, edgemarkers = edgemarkers, edgecolormap = bcmap, + show_colorbar = ctx[:show_colorbar], aspect = ctx[:aspect], xlabel = ctx[:xlabel], ylabel = ctx[:ylabel], @@ -358,6 +359,7 @@ function gridplot!(ctx, TP::Type{PlutoVistaType}, ::Type{Val{3}}, grid) facemarkers = facemarkers, gridscale = ctx[:gridscale], facecolormap = bcmap, + show_colorbar = ctx[:show_colorbar], outlinealpha = ctx[:outlinealpha], xlabel = ctx[:xlabel], ylabel = ctx[:ylabel], diff --git a/src/pyplot.jl b/src/pyplot.jl index c160424..df82050 100644 --- a/src/pyplot.jl +++ b/src/pyplot.jl @@ -231,18 +231,20 @@ function gridplot!(ctx, TP::Type{PyPlotType}, ::Type{Val{2}}, grid) cmap = PyPlot.ColorMap(cmap, length(cmap)), vmin = 1.0, vmax = length(cmap),) - if ctx[:colorbar] == :horizontal - cbar = fig.colorbar(cdata; - ax = ax, - ticks = collect(1:length(cmap)), - orientation = "horizontal",) - end + if ctx[:show_colorbar] + if ctx[:colorbar] == :horizontal + cbar = fig.colorbar(cdata; + ax = ax, + ticks = collect(1:length(cmap)), + orientation = "horizontal",) + end - if ctx[:colorbar] == :vertical - cbar = fig.colorbar(cdata; - ax = ax, - ticks = collect(1:length(cmap)), - orientation = "vertical",) + if ctx[:colorbar] == :vertical + cbar = fig.colorbar(cdata; + ax = ax, + ticks = collect(1:length(cmap)), + orientation = "vertical",) + end end ax.triplot(tridat...; color = "k", linewidth = ctx[:linewidth])