Draw lines between subplots GMT

Hello guys,

I am trying to insert lines between subplots but sometimes it does not plot in a correct way , it may disappear or becomes shorter than expected.
Is there any possible solution to overcome this problem?


gmt begin Land png


gmt subplot begin 2x2 -Fs18c/10c -M0.2 #-T"Earthquake Inspection"

gmt subplot set 2 

gmt basemap -R398/412/3862.2/3866.1  -JX18c/21.7c $x+l"Time (s)" $y+l"Distance (km)" -BWSen

gmt subplot set 1 

   gmt basemap -R398/412/3865/3865.475  -JX? $x $y -BwSen #+t"Event: 20200603093137 M6.1"

gmt subplot set 3
   gmt basemap -R398/412/3863/3863.475  -JX? $x+l"Time (s)" $y -BwSen #+t"Event: 20200603093137 M6.1"

gmt subplot end

gmt psxy -W1p -Cred,green -Xf0c -Yf0c<< EOF

8.1 3.7
8.77 4.9
8.1 2.8
8.77 1

8.1 7.4
8.77 5.6
8.1 8.
8.77 8.6

gmt end show

I want to move green line to subplot corner, but seems does not work.

@Joaquim any suggestion boss :slight_smile:

I am not sure what the “region” (i.e., -R) is for the subplot after you end it since nothing was set. I think the dimensions of the whole subplot goes into a hidden -JXwidth/height but not sure what -R might be set to. You could try to add -R to your line-drawing psxy with what you think it should be given your coordinates.

Hmm, this raises the issue that we don’t have any option in modern mode to save a non-closed postscript file that we could fine tune later with the classic mode, like adding lines with paper coordinates as this case is bagging to.

Would defeat the purpose of modern mode I think. Should not be a problem to draw some custom lines as attempted above in modern mode.

You keep forgetting that GMT.jl is almost all classic only, but subplots are modern.

Well, that is not something that is going to be back ported to modern mode CLI etc, so you will need to do whatever you need to do on the Julia side.

I was thinking on this on a programmers perspective only but it actually has a use for users also (I’m sure Kristof would agree). Imagine some complicated basemap made in modern and to which a simpler and variable plotting elements need to be added on a regular basis. We can do that in classic but not in modern.

As fo doing it in Julia, I think I came out with a solution:

  • Before calling gmt end steal the ps file from its temporary location (this the part that needs some investigation on how to do it)
  • Call gmt end to do the clean up.

Yes, this was the feature I suggested as underlay support in modern mode in https://github.com/GenericMappingTools/gmt/discussions/4995. The conclusion of that discussion was that it would complicate modern mode too much.

This is not good. I don’t remember that discussion nor, by consequence, what I was thinking back then. But I’m proposing here is quite simple and would not complicate modern at all. Just an option to let go the PS file without closing it.