# Coloring error bars

**URL:** <https://forum.generic-mapping-tools.org/t/coloring-error-bars/919>\
**Category:** Q&A\
**Created:** [September 30, 2020, 12:23pm UTC](https://forum.generic-mapping-tools.org/t/coloring-error-bars/919 "2020-09-30T12:23:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yacob](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yacob/32/576_2.png) [@Yacob](https://forum.generic-mapping-tools.org/u/Yacob)\
**Post date:** [September 30, 2020, 12:23pm UTC](https://forum.generic-mapping-tools.org/t/coloring-error-bars/919/1 "2020-09-30T12:23:59Z")

</div>

I would like to colour error bar using the command below (GMT6) based on the error\_bar\_values.

```auto
gmt makecpt -T0./.6/0.1 -Chaxby -Z > temp.cpt
 gmt plot file_(lat,long, **error_bar** ) -Ctemp.cpt -Ey0.2/.75p,solid -Bya1g.2+l"[mm/yr]" -BSWne -Bxa1g1
gmt colorbar -Ctemp.cpt -Dx1c/1c+w2c/0.2c+jLB+h -Bx.1f.1+l"error" -By+lmm/yr --FONT_ANNOT_PRIMARY=5p

```

This seems not working? the error message being:  
**plot [WARNING]: Mismatch between actual (3) and expected (4) fields near line 1 in file**

---

<div class="post-metadata">

**Author:** ![MarceloBanik](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/marcelobanik/32/479_2.png) [@MarceloBanik](https://forum.generic-mapping-tools.org/u/MarceloBanik)\
**Post date:** [September 30, 2020, 4:13pm UTC](https://forum.generic-mapping-tools.org/t/coloring-error-bars/919/2 "2020-09-30T16:13:29Z")

</div>

I think your input data should be x,y,z,error  
you could do z=error  
and you could try something like:  
`echo "-45 -23 0.2 1" | gmt psxy -R-50/-40/-25/-21 -JX10c -Ctemp.cpt -Ey+w0.2+p0.75p,solid+cf -Bya1+l"[mm/yr]" -BSWne -Bxa1 > test.ps`  
which results in:

 ![test](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/3de4ccd99bde26d4d4b6d2d8dcc9bbf0b57b23cd.png)

---

<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:** [September 30, 2020, 4:33pm UTC](https://forum.generic-mapping-tools.org/t/coloring-error-bars/919/3 "2020-09-30T16:33:05Z")

</div>

You can use the trick of duplicating your third column with **-i0-2,2** in the `plot` command.

---

<div class="post-metadata">

**Author:** ![Yacob](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yacob/32/576_2.png) [@Yacob](https://forum.generic-mapping-tools.org/u/Yacob)\
**Post date:** [October 1, 2020, 6:47am UTC](https://forum.generic-mapping-tools.org/t/coloring-error-bars/919/4 "2020-10-01T06:47:53Z")

</div>

Thank you very much, Marcelo. The +cf did the trick following your recommendations.

---

<div class="post-metadata">

**Author:** ![Yacob](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/yacob/32/576_2.png) [@Yacob](https://forum.generic-mapping-tools.org/u/Yacob)\
**Post date:** [October 1, 2020, 6:55am UTC](https://forum.generic-mapping-tools.org/t/coloring-error-bars/919/5 "2020-10-01T06:55:20Z")

</div>

Hi Joaquim,  
I have started to change all my GMT 5 version to GMT6. I must say it saves so much time specifically fiddling to insert a text for the intended places. Simply awesome. GMT6 rocks !!!

Yes, I did try to feed the plot command 4 parameters repeating the third one before I sent my question to the community but it still failed, then when I insert +cf as recommended by @MarceloBanik, it is now working.
