using MIRTjim: jim, prompt, mid3 using AxisArrays: AxisArray using ColorTypes: RGB using OffsetArrays: OffsetArray using Unitful using Unitful: μm, s import Plots using InteractiveUtils: versioninfo isinteractive() ? jim(:prompt, true) : prompt(:draw); x, y = 1:9, 1:7 f(x,y) = x * (y-4)^2 z = f.(x, y') # 9 × 7 array jim(z ; xlabel="x", ylabel="y", title="f(x,y) = x * (y-4)^2") Plots.heatmap(z, title="heatmap") isinteractive() && prompt(); jim(z, "hello") zo = OffsetArray(z, (-3,-1)) jim(zo, "OffsetArray example") f3 = reshape(1:(9*7*6), (9, 7, 6)) jim(f3, "3D"; size=(600, 300)) x11 = reshape(1:(5*6*11), (5, 6, 11)) jim(x11, "nrow=3"; nrow=3) jim(x11, "ncol=6"; ncol=6, size=(600, 200)) x,y,z = -20:20, -10:10, 1:30 xc = reshape(x, :, 1, 1) yc = reshape(y, 1, :, 1) zc = reshape(z, 1, 1, :) rx = reshape(range(2, 19, length(z)), size(zc)) ry = reshape(range(2, 9, length(z)), size(zc)) cone = @. abs2(xc / rx) + abs2(yc / ry) < 1 jim(mid3(cone); color=:cividis, title="mid3") xticks = ([1, length(x), length(x)+length(z)], ["$(x[begin])", "$(x[end]), $(z[begin])", "$(z[end])"]) yticks = ([1, length(y), length(y)+length(z)], ["$(y[begin])", "$(y[end]), $(z[begin])", "$(z[end])"]) Plots.plot!(;xticks , yticks) z3 = reshape(1:(9*7*6), (7, 9, 6)) z4 = [z3[:,:,(j-1)*3+i] for i=1:3, j=1:2] jim(z4, "Arrays of images") x = 0.1*(1:9)u"m/s" y = (1:7)u"s" zu = x * y' jim(x, y, zu, "units" ; clim=(0,7).*u"m", xlabel="rate", ylabel="time", colorbar_title="distance") x = range(-2,2,201) * 1u"m" y = range(-1.2,1.2,150) * 1u"m" # Δy ≢ Δx z = @. sqrt(x^2 + (y')^2) ≤ 1u"m" jim(x, y, z, "Axis units with unequal spacing"; color=:cividis, size=(600,350)) x = (2:9) * 1μm y = (3:8) * 1/s z = (4:7) * 1μm * 1s f3d = rand(8, 6, 4) # * s^2 jim(x, y, z, f3d, "3D with axis units") jim((x, y, z), f3d, "axes tuple") x = (1:9)μm y = (1:7)μm/s za = AxisArray(x * y'; x, y) jim(za, "AxisArray") jim(rand(RGB{Float32}, 8, 6); title="RGB image") jim(:defs) jim(:push!) # save current defaults jim(:colorbar, :none) # disable colorbar for subsequent figures jim(:yflip, false) # have "y" axis increase upward jim(rand(9,7), "rand", color=:viridis) # kwargs... passed to heatmap() jim(:pop!); # restore p1 = jim(rand(5,7); prompt=false) p2 = jim(rand(6,8); color=:viridis, prompt=false) p3 = jim(rand(9,7); color=:cividis, title="plot 3", prompt=false) jim(p1, p2, p3; layout=(1,3), gui=true, size = (600,200))