# Draw lines between subplots GMT

**URL:** <https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398>\
**Category:** Q&A\
**Created:** [November 1, 2022, 6:47am UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398 "2022-11-01T06:47:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![aqeel-magsi](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@aqeel-magsi](https://forum.generic-mapping-tools.org/u/aqeel-magsi)\
**Post date:** [November 1, 2022, 6:47am UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398/1 "2022-11-01T06:47:48Z")

</div>

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?

```
#!/bin/bash

gmt begin Land png

  x=-Bxa3f1
  y=-Bya1f1

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

>-Z0
8.1 3.7
8.77 4.9
>-Z0
8.1 2.8
8.77 1

>-Z1
8.1 7.4
8.77 5.6
>-Z1
8.1 8.
8.77 8.6
EOF

gmt end show

```

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

 ![Land](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/c/c1086310b1d192971d2cc965e4e43a08c7e0d81f.png)

---

<div class="post-metadata">

**Author:** ![aqeel-magsi](https://avatars.discourse-cdn.com/v4/letter/a/f14d63/32.png) [@aqeel-magsi](https://forum.generic-mapping-tools.org/u/aqeel-magsi)\
**Post date:** [November 7, 2022, 3:45am UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398/2 "2022-11-07T03:45:13Z")

</div>

@Joaquim any suggestion boss 🙂

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [November 7, 2022, 9:32am UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398/3 "2022-11-07T09:32:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 7, 2022, 11:54am UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398/4 "2022-11-07T11:54:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [November 7, 2022, 2:17pm UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398/5 "2022-11-07T14:17:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 7, 2022, 2:50pm UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398/6 "2022-11-07T14:50:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [November 8, 2022, 11:46am UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398/7 "2022-11-08T11:46:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 8, 2022, 12:39pm UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398/8 "2022-11-08T12:39:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![maxrjones](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/maxrjones/32/2698_2.png) [@maxrjones](https://forum.generic-mapping-tools.org/u/maxrjones)\
**Post date:** [November 8, 2022, 3:50pm UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398/9 "2022-11-08T15:50:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 8, 2022, 5:25pm UTC](https://forum.generic-mapping-tools.org/t/draw-lines-between-subplots-gmt/3398/10 "2022-11-08T17:25:06Z")

</div>

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.
