Thanks for providing a solution. Your solution solves the issue and the code is now running very fast thanks to converting Data into Array.
Data = Array(Data)
I wrote a code to animate the output of my hydrological model by moving a slider. When I run in Jupyter notebook in Visual Studio Code the plots open in GLMakie but when I run it in REPL it opens as a png. The question how can I force it to open in Makie when I run it in Visual Studio Code when running it in the REPL?
function HEATMAP_TIME(;Path=Path, NameOutput="q_land", Layer=1)
GLMakie.activate!
Makie.inline!(false) # Make sure to inline plots into Documenter output!
Output_NCDatasets = NCDatasets.NCDataset(Path)
Data = Output_NCDatasets[NameOutput]
Data = Array(Data)
Dimensions = length(size(Data))
if Dimensions == 3
N_Lon = size(Data)[1]
N_Lat = size(Data)[2]
N_Time = size(Data)[3]
elseif Dimensions == 4
N_Lon = size(Data)[1]
N_Lat = size(Data)[2]
N_Time = size(Data)[4]
end
Pmin, Pmax = extrema(x for x â skipmissing(Data) if !isnan(x))
@show Pmin, Pmax
function DATA_3D_2_2D(Data; iTime=iTime, Dimensions=Dimensions, Layer=Layer)
if Dimensions == 4
return Data[:,:, Layer, iTime]
elseif Dimensions == 3
return Data[:,:, iTime]
end
end
Fig = Figure(size=(Width, Height * 4.0))
Ax_1 = Axis(Fig[1, 1], title=NameOutput, xlabelsize=xlabelSize, ylabelsize=xlabelSize, xticksize=xticksize, xgridvisible=xgridvisible, ygridvisible=xgridvisible)
sg = SliderGrid(Fig[2, 1],
(label="iTime", range=1:1:N_Time, startvalue=1),
width=550, tellheight=true)
iTime = sg.sliders[1].value
Data_Time = lift((iTime) -> DATA_3D_2_2D(Data; iTime=iTime, Dimensions), iTime)
Data_Plot = heatmap!(Ax_1, 1:N_Lon, 1:N_Lat, Data_Time, colorrange=(Pmin, Pmax), colormap =:hawaii50)
Colorbar(Fig[1, 2], Data_Plot; label=NameOutput, width=20, ticks = Pmin:(Pmax-Pmin)/5:Pmax)
Fig
end
HEATMAP_TIME(;Path=Path_Output, NameOutput="vwc")