It appears that the current API of GMT.jl allows complex plots using either imshow
or inset
, but not both. In classic mode (I guess that is what it is called?) there is no imshow!
function:
help?> imshow!
search: imshow
Couldn't find imshow!
Perhaps you meant imshow, ispow2, @show, show or image!
No documentation found.
Binding imshow! does not exist.
On the other hand, in modern mode inset
doesn’t work:
function inset_modern()
try
gmtbegin("test_insets.pdf")
coast(
proj = :Mercator,
region = (110, 210, -40, 40),
figsize = 15,
frame = :auto,
land = :dimgray,
shore = :thinner,
)
basemap(
frame = (; grid = :auto), # Without this there is a second error.
inset = (; anchor = :BL, width = 3.8, offset = (10.9, 6)),
box = (; fill = :white, pen = 1, clearance = 0.1, shaded = true),
)
coast(
region = :global,
proj = (; name = :ortho, center = (120, 0), parallel = 3.8),
frame = (; grid = :auto),
land = :brown,
area = 5000,
DCW = (; country = "AU", fill = :bisque),
xshift = 10.9,
yshift = 6,
)
gmtend()
catch e
gmtend()
throw(e)
end
end
julia> inset_modern()
basemap [ERROR]: Option -F is only allowed with -L and -T
ERROR: Something went wrong when calling the module. GMT error number = 72
Stacktrace:
[1] inset_modern()
@ Main ~/hazcode/GMT/julia_GMT/test_insets.jl:73
[2] top-level scope
@ REPL[6]:1
caused by: Something went wrong when calling the module. GMT error number = 72
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] gmt(cmd::String, args::Nothing)
@ GMT ~/vcs/GMT.jl/src/gmt_main.jl:284
[3] finish_PS_module(d::Dict{Symbol, Any}, cmd::Vector{String}, opt_extra::String, K::Bool, O::Bool, finish::Bool, args::Nothing)
@ GMT ~/vcs/GMT.jl/src/common_options.jl:3407
[4] basemap(cmd0::String, arg1::Nothing; first::Bool, kwargs::Base.Iterators.Pairs{Symbol, NamedTuple, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:frame, :inset, :box), Tuple{NamedTuple{(:grid,), Tuple{Symbol}}, NamedTuple{(:anchor, :width, :offset), Tuple{Symbol, Float64, Tuple{Float64, Int64}}}, NamedTuple{(:fill, :pen, :clearance, :shaded), Tuple{Symbol, Int64, Float64, Bool}}}}})
@ GMT ~/vcs/GMT.jl/src/psbasemap.jl:67
[5] inset_modern()
@ Main ~/hazcode/GMT/julia_GMT/test_insets.jl:55
[6] top-level scope
@ REPL[6]:1
The working version of the above function using classic mode:
function inset_classic()
coast(
region = (110, 170, -44, -9),
proj = :Mercator,
figsize = 15,
shore = :thinner,
land = :brown,
water = :azure1,
)
basemap!(
inset = (;
anchor = :BL,
width = 3.8,
offset = (10.9, 6),
),
box = (;
fill = :white,
pen = 1,
clearance = 0.1,
shaded = true,
),
)
coast!(
region = :global,
proj = (; name = :ortho, center = (120, 0), parallel = 3.8),
frame = (; grid = :auto),
land = :brown,
area = 5000,
DCW = (; country = "AU", fill = :bisque),
xshift = 10.9,
yshift = 6,
)
end
Now, the actual plot I am trying to make has multiple layers:
- coast
- grdimage + grdcontour + colorbar
- imshow (using an GMTDataSet, so image! is not a substitute I think)
- arrows + scatter + legend
- basemap (inset) + coast + scatter
Is there a way to have both imshow and inset layers, that I am missing?
Cheers,
Leon