@@ -113,6 +113,7 @@ function subplot(fim::String, stop::Bool, d::Dict{Symbol, Any})
113113 gmt (" gmtset MAP_FRAME_TYPE fancy" )
114114 catch ; resetGMT ()
115115 end
116+ remove_map_origin () # Remove MAP_ORIGIN_X and MAP_ORIGIN_Y from the gmt.conf.0.subplot file (see comments in function)
116117 IamSubplot[], IamModern[] = true , true
117118 elseif (do_set)
118119 (! IamSubplot[]) && error (" Cannot call subplot(set, ...) before setting dimensions" )
@@ -216,4 +217,31 @@ function mura_arg(arg)::Dict
216217 else d = (isa (arg, NamedTuple)) ? nt2dict (arg) : arg
217218 end
218219 d
220+ end
221+
222+ # --------------------------------------------------------------------------
223+ function remove_map_origin ()
224+ # Remove MAP_ORIGIN_X and MAP_ORIGIN_Y from the gmt.conf.0.subplot file
225+ # The problem: GMT CLI when it creates the gmt.conf.0.subplot file, does not set MAP_ORIGIN_X and MAP_ORIGIN_Y
226+ # but because we fiddle a lot with themes and make the classic mode behave like modern, we end up setting them
227+ # and that has a drastic effect of burning permanently in the GMT_keyword_updated[] internal variable, AND THERE
228+ # IS NO WAY TO UNSET things inside GMT_keyword_updated[] from externals. When gmt_begin() is called, the
229+ # gmt.conf.0.subplot file is created and the MAP_ORIGIN_X and MAP_ORIGIN_Y are set. But this SCREWS the location
230+ # of the colorbars when we have subplots because they all overlap each other. The only solution found is to remove
231+ # the MAP_ORIGIN_X and MAP_ORIGIN_Y from the gmt.conf.0.subplot file.
232+ # WARNING: If we ever implement the 'figure' case, this function will need to be modified to account for the
233+ # figure number. As it is, the "0" in gmt.conf.0.subplot stands for figure 0.
234+ API = unsafe_load (convert (Ptr{GMTAPI_CTRL}, G_API[]))
235+ session_dir = unsafe_string (API. gwf_dir)
236+ fname = session_dir * filesep * " gmt.conf.0.subplot"
237+ ! isfile (fname) && return
238+ lines = readlines (fname)
239+ filtered = filter (l -> ! startswith (l, " MAP_ORIGIN_" ), lines)
240+ length (filtered) == length (lines) && return nothing # Nothing to remove
241+ open (fname, " w" ) do io
242+ for l in filtered
243+ println (io, l)
244+ end
245+ end
246+ return nothing
219247end
0 commit comments