# Plot data on Map with GMT.jl

**URL:** <https://discourse.julialang.org/t/plot-data-on-map-with-gmt-jl/61937>\
**Category:** New to Julia\
**Tags:** plotting, gmt\
**Created:** [May 27, 2021, 3:11pm UTC](https://discourse.julialang.org/t/plot-data-on-map-with-gmt-jl/61937 "2021-05-27T15:11:47Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![mixstam1453](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mixstam1453/32/23731_2.png) [@mixstam1453](https://discourse.julialang.org/u/mixstam1453)\
**Post date:** [May 31, 2021, 8:17am UTC](https://discourse.julialang.org/t/plot-data-on-map-with-gmt-jl/61937/8 "2021-05-31T08:17:59Z")

</div>

Hello, have a good week.  
Thanks again.  
I plot my text well,

 ![GMTjl_rob](https://global.discourse-cdn.com/julialang/original/3X/e/a/eadf437028128628fb5faaff16e21f95ab5156bd.jpeg)  
the code is here:

```julia

text(["mean = 170 W/m^2"],figsize=30,frame=(annot=""),region=(0,30,0,30), proj=:linear, x=7, y=9 ,font=(10,:red)) 
text!(["20 May 1994"],frame=(annot=""),region=(0,30,0,30), proj=:linear, x=1, y=9 ,font=(10,"Palatino-Italic",:darkgreen)) 
text!(["Outgoing Solar Radiation at TOA"],angle=7, frame=(annot=""),region=(0,30,0,30), proj=:linear, x=13, y=9.2 ,font=(10,"Courier-Bold",:purple))

coast!(region=(-180, 180, -90, 90), 
    proj=:Robinson,figsize=16,frame=(annot=45, grid=45,ticks=10)) # make the map
topo = makecpt(color=:rainbow, range=(0,225,20), continuous=true) #make colorbar
grdimage!(G2, coast=true,color=topo,
          frame=(annot=45,grid=45,title="CERES OSR")) # plot my gridarray
colorbar!(pos=(anchor=:BC,length=(12.5,0.6), horizontal=true, offset=(0,1.0)),
          color=topo, frame=(ylabel="W/m^2",), fmt=:jpg, show=true) # plot colorbar

```

but about the size of the image i can’t fix it with `GMT.FMT[1] = "png"` or `ENV["JULIA_GMT_IMGFORMAT"] = "png";` , because when i execute this and then plot:

```julia
grdimage(G2, figsize=(30,14),coast=true,color=topo,frame=(annot=45,grid=45,title="CERES OSR")) # plot my gridarray

```

I get the larger size but when i try then colorbar!() or coast!() or text!() (something with !) i get this error:

```julia
julia> colorbar!(pos=(anchor=:BC,length=(12.5,0.6), horizontal=true, offset=(0,1.0)),             
                 color=topo, frame=(ylabel="W/m^2",), fmt=:jpg, show=true) # plot colorbar        
Error: /undefined in A
Operand stack:
   0
Execution stack:
   %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1990 1 3 %oparray_pop 1989 1 3 %oparray_pop 1977 1 3 %oparray_pop 1833 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
   --dict:728/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)--
Current allocation mode is local
Current file position is 9647080
psconvert [ERROR]: System call [gs -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true '/tmp/GMTjl_tmp.ps' 2> './psconvert_71425c.bb'] returned error 256.
ERROR: Something went wrong when calling the module. GMT error number =
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] gmt(::String)
   @ GMT ~/.julia/packages/GMT/wprG1/src/gmt_main.jl:289
 [3] showfig(d::Dict{Symbol, Any}, fname_ps::String, fname_ext::String, opt_T::String, K::Bool, fname::String)
   @ GMT ~/.julia/packages/GMT/wprG1/src/common_options.jl:2951
 [4] finish_PS_module(d::Dict{Symbol, Any}, cmd::Vector{String}, opt_extra::String, K::Bool, O::Bool, finish::Bool, args::GMT.GMTcpt)
   @ GMT ~/.julia/packages/GMT/wprG1/src/common_options.jl:3101
 [5] finish_PS_module(d::Dict{Symbol, Any}, cmd::String, opt_extra::String, K::Bool, O::Bool, finish::Bool, args::GMT.GMTcpt)
   @ GMT ~/.julia/packages/GMT/wprG1/src/common_options.jl:3028
 [6] colorbar(cmd0::String, arg1::Nothing; first::Bool, kwargs::Base.Iterators.Pairs{Symbol, Any, NTuple{5, Symbol}, NamedTuple{(:pos, :color, :frame, :fmt, :show), Tuple{NamedTuple{(:anchor, :length, :horizontal, :offset), Tuple{Symbol, Tuple{Float64, Float64}, Bool, Tuple{Int64, Float64}}}, GMT.GMTcpt, NamedTuple{(:ylabel,), Tuple{String}}, Symbol, Bool}}})
   @ GMT ~/.julia/packages/GMT/wprG1/src/psscale.jl:85
 [7] #colorbar!#358
   @ ~/.julia/packages/GMT/wprG1/src/psscale.jl:93 [inlined]
 [8] top-level scope
   @ REPL[596]:1

```

Similar error i get even if i code:

```julia
text(["mean = 170 W/m^2"],figsize=30,frame=(annot=""),region=(0,30,0,30), proj=:linear, x=7, y=9 ,font=(10,:red)) 
text!(["20 May 1994"],frame=(annot=""),region=(0,30,0,30), proj=:linear, x=1, y=9 ,font=(10,"Palatino-Italic",:darkgreen)) 

```

```julia
julia> text!(["20 May 1994"],frame=(annot=""),region=(0,30,0,30), proj=:linear, x=1, y=9 ,font=(10,"Palatino-Italic",:darkgreen))                  
Error: /undefined in A
Operand stack:
   0
Execution stack:
   %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1990 1 3 %oparray_pop 1989 1 3 %oparray_pop 1977 1 3 %oparray_pop 1833 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
   --dict:728/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)--
Current allocation mode is local
Current file position is 20857
psconvert [ERROR]: System call [gs -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true '/tmp/GMTjl_tmp.ps' 2> './psconvert_71425c.bb'] returned error 256.
ERROR: Something went wrong when calling the module. GMT error number =
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] gmt(::String)
   @ GMT ~/.julia/packages/GMT/wprG1/src/gmt_main.jl:289
 [3] showfig(d::Dict{Symbol, Any}, fname_ps::String, fname_ext::String, opt_T::String, K::Bool, fname::String)
   @ GMT ~/.julia/packages/GMT/wprG1/src/common_options.jl:2951
 [4] finish_PS_module(::Dict{Symbol, Any}, ::Vector{String}, ::String, ::Bool, ::Bool, ::Bool, ::GMT.GMTdataset{Float64, 2}, ::Vararg{Any, N} where N)
   @ GMT ~/.julia/packages/GMT/wprG1/src/common_options.jl:3101
 [5] finish_PS_module(::Dict{Symbol, Any}, ::String, ::String, ::Bool, ::Bool, ::Bool, ::GMT.GMTdataset{Float64, 2}, ::Vararg{Any, N} where N)
   @ GMT ~/.julia/packages/GMT/wprG1/src/common_options.jl:3028
 [6] text(cmd0::String, arg1::GMT.GMTdataset{Float64, 2}; first::Bool, kwargs::Base.Iterators.Pairs{Symbol, Any, NTuple{4, Symbol}, NamedTuple{(:frame, :region, :proj, :font), Tuple{String, NTuple{4, Int64}, Symbol, Tuple{Int64, String, Symbol}}}})
   @ GMT ~/.julia/packages/GMT/wprG1/src/pstext.jl:127
 [7] text(txt::Vector{String}; x::Int64, y::Int64, first::Bool, kwargs::Base.Iterators.Pairs{Symbol, Any, NTuple{4, Symbol}, NamedTuple{(:frame, :region, :proj, :font), Tuple{String, NTuple{4, Int64}, Symbol, Tuple{Int64, String, Symbol}}}})
   @ GMT ~/.julia/packages/GMT/wprG1/src/pstext.jl:144
 [8] #text!#370
   @ ~/.julia/packages/GMT/wprG1/src/pstext.jl:146 [inlined]
 [9] top-level scope
   @ REPL[598]:1 

```

To enlarge image size it is not my issue for now, but generally i would like to know how to achive this in future. I really appreciate your prompt responses and GMT.jl has a lot of features for further study.

Cheers,  
Michael

---

_[View the full topic](https://discourse.julialang.org/t/plot-data-on-map-with-gmt-jl/61937)._
