diff --git a/Project.toml b/Project.toml index 14df57b..778f4ed 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "GridVisualize" uuid = "5eed8a63-0fb0-45eb-886d-8d5a387d12b8" authors = ["Juergen Fuhrmann ", "Patrick Jaap "] -version = "1.11.0" +version = "1.12.0" [deps] ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4" diff --git a/src/dispatch.jl b/src/dispatch.jl index 950887f..3f0e043 100644 --- a/src/dispatch.jl +++ b/src/dispatch.jl @@ -367,8 +367,9 @@ function default_plot_kwargs() ), :scene3d => Pair( :Axis3, - "3D plot type of Makie scene. Alternaitve to `:Axis3` is `:LScene`" + "3D plot type of Makie scene. Alternative to `:Axis3` is `:LScene`" ), + :viewmode => Pair(:fit, "Axis3d viewmode for Makie plots. Possible values :fit or :free"), :fignumber => Pair(1, "Figure number (PyPlot)"), :framepos => Pair(1, "Subplot position in frame (VTKView)"), :subplot => Pair((1, 1), "Private: Actual subplot"), @@ -377,7 +378,7 @@ function default_plot_kwargs() :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"), - :show_colorbar => Pair(true, "Show color bar next to grid plots"), + :show_colorbar => Pair(true, "Show color bar next to plots"), :slice => Pair(nothing, "Plot a dim-1 slice along a hyperplane expression :(αx ± βy [± γz] ± δ)) or a fixed axis pair, e.g., :x => 3") ) end diff --git a/src/makie.jl b/src/makie.jl index 3ac6b57..2651c50 100644 --- a/src/makie.jl +++ b/src/makie.jl @@ -670,23 +670,25 @@ function makescene2d(ctx, key) GL[1, 1] = ctx[:scene] # , fontsize=0.5*ctx[:fontsize],ticklabelsize=0.5*ctx[:fontsize] - if ctx[:colorbar] == :vertical - GL[1, 2] = XMakie.Colorbar( - ctx[:figure], - ctx[key]; - width = 10, - ticks = unique(ctx[:cbarticks]), - tickformat = "{:.2e}", - ) - elseif ctx[:colorbar] == :horizontal - GL[2, 1] = XMakie.Colorbar( - ctx[:figure], - ctx[key]; - height = 10, - ticks = unique(ctx[:cbarticks]), - vertical = false, - tickformat = "{:.2e}", - ) + if ctx[:show_colorbar] + if ctx[:colorbar] == :vertical + GL[1, 2] = XMakie.Colorbar( + ctx[:figure], + ctx[key]; + width = 10, + ticks = unique(ctx[:cbarticks]), + tickformat = "{:.2e}", + ) + elseif ctx[:colorbar] == :horizontal + GL[2, 1] = XMakie.Colorbar( + ctx[:figure], + ctx[key]; + height = 10, + ticks = unique(ctx[:cbarticks]), + vertical = false, + tickformat = "{:.2e}", + ) + end end return GL end @@ -940,13 +942,17 @@ function makeaxis3d(ctx) XMakie = ctx[:Plotter] if ctx[:scene3d] == :LScene # "Old" LScene with zoom-in functionality - return XMakie.LScene(ctx[:figure]) + lim = ctx[:limits] + lim = Observable(Rect3f(Vec3f(lim[1], lim[3], lim[5]), Vec3f(lim[2], lim[4], lim[6]))) + scene = XMakie.LScene(ctx[:figure], scenekw = (; limits = lim)) + return scene else # "New" Axis3 with prospective new stuff by Julius. return XMakie.Axis3( ctx[:figure]; aspect = :data, - viewmode = :fit, + viewmode = ctx[:viewmode], + limits = ctx[:limits], elevation = ctx[:elev] * π / 180, azimuth = ctx[:azim] * π / 180, perspectiveness = ctx[:perspectiveness], @@ -977,31 +983,32 @@ function makescene3d(ctx) end GL[1, 1] = ctx[:scene] # Horizontal or vertical colorbar - if haskey(ctx, :crange) - if ctx[:colorbar] == :vertical - GL[1, 2] = XMakie.Colorbar( - ctx[:figure]; - colormap = ctx[:colormap], - colorrange = ctx[:crange], - ticks = map(d -> d.c, ctx[:data]), - tickformat = "{:.2e}", - width = 15, - ticklabelsize = 0.5 * ctx[:fontsize], - ) - elseif ctx[:colorbar] == :horizontal - GL[2, 1] = XMakie.Colorbar( - ctx[:figure]; - colormap = ctx[:colormap], - colorrange = ctx[:crange], - ticks = map(d -> d.c, ctx[:data]), - tickformat = "{:.2e}", - height = 15, - ticklabelsize = 0.5 * ctx[:fontsize], - vertical = false, - ) + if ctx[:show_colorbar] + if haskey(ctx, :crange) + if ctx[:colorbar] == :vertical + GL[1, 2] = XMakie.Colorbar( + ctx[:figure]; + colormap = ctx[:colormap], + colorrange = ctx[:crange], + ticks = map(d -> d.c, ctx[:data]), + tickformat = "{:.2e}", + width = 15, + ticklabelsize = 0.5 * ctx[:fontsize], + ) + elseif ctx[:colorbar] == :horizontal + GL[2, 1] = XMakie.Colorbar( + ctx[:figure]; + colormap = ctx[:colormap], + colorrange = ctx[:crange], + ticks = map(d -> d.c, ctx[:data]), + tickformat = "{:.2e}", + height = 15, + ticklabelsize = 0.5 * ctx[:fontsize], + vertical = false, + ) + end end end - # Put the status label into protrusion space on the bottom of the scene GL[1, 1, XMakie.Bottom()] = XMakie.Label( ctx[:figure], @@ -1038,6 +1045,11 @@ function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grid) XMakie = ctx[:Plotter] xyzmin, xyzmax = xyzminmax(grid, ctx[:gridscale]) xyzstep = (xyzmax - xyzmin) / 100 + ctx[:limits] = ( + xyzmin[1], xyzmax[1], + xyzmin[2], xyzmax[2], + xyzmin[3], xyzmax[3], + ) function adjust_planes(xplane, yplane, zplane) ctx[:ixplane] = max(xyzmin[1], min(xyzmax[1], xplane)) @@ -1195,6 +1207,7 @@ function gridplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grid) ctx[:status] = Observable(" ") + XMakie.reset_limits!(ctx[:scene]) add_scene!(ctx, makescene_grid(ctx)) else @@ -1250,6 +1263,12 @@ function scalarplot!(ctx, TP::Type{MakieType}, ::Type{Val{3}}, grids, parentgrid fstep = 0.1 end + ctx[:limits] = ( + xyzmin[1], xyzmax[1], + xyzmin[2], xyzmax[2], + xyzmin[3], xyzmax[3], + ) + ctx[:ixplanes] = collect(ctx[:xplanes]) * ctx[:gridscale] ctx[:iyplanes] = collect(ctx[:yplanes]) * ctx[:gridscale] ctx[:izplanes] = collect(ctx[:zplanes]) * ctx[:gridscale]