# Mispositioned Colorbars in Subplots

**URL:** <https://forum.generic-mapping-tools.org/t/mispositioned-colorbars-in-subplots/4497>\
**Category:** Q&A\
**Created:** [December 8, 2023, 5:09am UTC](https://forum.generic-mapping-tools.org/t/mispositioned-colorbars-in-subplots/4497 "2023-12-08T05:09:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![richannan](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@richannan](https://forum.generic-mapping-tools.org/u/richannan)\
**Post date:** [December 8, 2023, 5:09am UTC](https://forum.generic-mapping-tools.org/t/mispositioned-colorbars-in-subplots/4497/1 "2023-12-08T05:09:32Z")

</div>

Dear friends,  
Please help me figure out the cause of the misplaced colorbars in the image below. I was expecting each colorbar to be positioned below its subplot; however, they are placed on top of each other at a weird position. I can use the offset feature in `-D` of `colorbar` to fix it, but I need to understand why this is happening; because the actual plot is a 3x3 subplot. Can someone kindly explain to me what I may be missing? I have ran it both GMT6.3.0 and 6.4.0, and the result is the same.

Below is the accompanying script.  
`UUUU.nc` can be ETOPO1, GEBCO or any bathymetric grid around Hawaii.  
Thanks very much.

```auto
gmt begin Jotter png
	gmt subplot begin 2x1 -A"(a)"+jTL+gwhite+o0.15i/0.07i -Fs6.2i/3i -M0.25i/0.4i -R-165/-150/15/30 -JQ6i
	    gmt subplot set 0 				
			gmt grd2cpt -Z UUUU.nc -L-10000/0 -Cturbo
			gmt grdimage UUUU.nc -I+d 
			gmt coast -Gpeachpuff4 -Df -Wthinnest 			
			gmt colorbar -DJBC -Bx2000 -By+lm
		gmt subplot set 1 				
			gmt grd2cpt -Z UUUU.nc -L-10000/0 -Cpolar
			gmt grdimage UUUU.nc -I+d 
			gmt coast -Gpeachpuff4 -Df -Wthinnest 
			gmt colorbar -DJBC -Bx2000 -By+lm		
	gmt subplot end	
gmt end show 

```

 ![Screenshot 2023-12-08 125155](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/c/ca5072bbd5774af8b9b9e17a773958ded2b3e126.jpeg)

---

<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:** [December 8, 2023, 10:18am UTC](https://forum.generic-mapping-tools.org/t/mispositioned-colorbars-in-subplots/4497/2 "2023-12-08T10:18:24Z")

</div>

Cannot reproduce it but also using 6.5 master. Must be an old bug then.

 ![Jotter](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/4/4e194acafcfcbd263a9f937c905c0c2cd250dd83.png)

---

<div class="post-metadata">

**Author:** ![richannan](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@richannan](https://forum.generic-mapping-tools.org/u/richannan)\
**Post date:** [January 15, 2024, 4:36am UTC](https://forum.generic-mapping-tools.org/t/mispositioned-colorbars-in-subplots/4497/3 "2024-01-15T04:36:48Z")

</div>

Dear @pwessel, I am writing to inform you that my problem has nothing to do with the GMT version. I have installed 6.5.0, but the problem is not resolved. The issue affects my current computer; because I ran the script in 6.1.0 on an different computer and everything was fine. My instincts says I have done something wrong somewhere to the GMT settings. This is because I once tampered with the gmt.conf file some time ago last year; and since then, `colorbar` is always mispositioned on my computer.

Please do you have any idea what may be the solution? Sorry to disturb you. Many thanks to you and your team for this wonderful software.

---

<div class="post-metadata">

**Author:** ![seisman](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/seisman/32/4_2.png) [@seisman](https://forum.generic-mapping-tools.org/u/seisman)\
**Post date:** [January 15, 2024, 7:13am UTC](https://forum.generic-mapping-tools.org/t/mispositioned-colorbars-in-subplots/4497/4 "2024-01-15T07:13:15Z")

</div>

I also can’t reproduce your issue with GMT 6.5.0.

Here are my suggestions:

1. Use GMT 6.5.0
2. Use `gmt begin Jotter png -C` so that the script won’t use any existing gmt.conf file
3. If `gmt begin -C` doesn’t help, then please add `gmt set GMT_VERBOSE debug` after the `gmt begin` command and post the long debugging message to the forum so that we can see what’s happening

---

<div class="post-metadata">

**Author:** ![richannan](https://avatars.discourse-cdn.com/v4/letter/r/bc79bd/32.png) [@richannan](https://forum.generic-mapping-tools.org/u/richannan)\
**Post date:** [January 15, 2024, 8:04am UTC](https://forum.generic-mapping-tools.org/t/mispositioned-colorbars-in-subplots/4497/5 "2024-01-15T08:04:13Z")

</div>

Hello @seisman,  
Thank you for the help; however, `gmt begin Jotter png -C` did not resolve it. So, I have uploaded the debugging message.  
[GMT\_Debug\_Result.txt](https://forum.generic-mapping-tools.org/uploads/short-url/l41Mr0mRihnb5ZUghCl9rlEfjR3.txt) (152.2 KB)
