Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "GridVisualize"
uuid = "5eed8a63-0fb0-45eb-886d-8d5a387d12b8"
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]
version = "1.11.0"
version = "1.12.0"

[deps]
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
Expand Down
5 changes: 3 additions & 2 deletions src/dispatch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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
Expand Down
103 changes: 61 additions & 42 deletions src/makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
Loading