# How represent colour bar with log scale?

**URL:** <https://forum.generic-mapping-tools.org/t/how-represent-colour-bar-with-log-scale/2993>\
**Category:** PyGMT Q&A\
**Created:** [June 3, 2022, 6:39am UTC](https://forum.generic-mapping-tools.org/t/how-represent-colour-bar-with-log-scale/2993 "2022-06-03T06:39:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adnan](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Adnan](https://forum.generic-mapping-tools.org/u/Adnan)\
**Post date:** [June 3, 2022, 6:39am UTC](https://forum.generic-mapping-tools.org/t/how-represent-colour-bar-with-log-scale/2993/1 "2022-06-03T06:39:41Z")

</div>

Hi Everyone,  
I just want to show my color bar with log scale. May someone suggest me how can I fixed this.

(Here is my script: no so professional because i am new to pygmt)

```python
fig = pygmt.Figure()
df = pygmt.blockmean(data=data, region=region, spacing=spacing)
grd = pygmt.xyz2grd(data=df, region=region, spacing=spacing)
df = pygmt.blockmean(data=data, region=region, spacing=spacing, summary="n")
grd = pygmt.xyz2grd(data=df, region=region, spacing=spacing,)
pygmt.makecpt(cmap='white,blue,red',series=[0,15000,3000],continuous=True)

fig.grdimage(grid=grd,region=region,cmap=True, frame=["a0.05f"],)
fig.coast(land="black", transparency=0, map_scale="jBR+w1k+o0.5c/0.8c+a+lkm")
fig.plot(x=d[2],y=d[1],style='i18p',color='red',pen='black',label='OOI',)
fig.colorbar(frame=["a+lEq.count (sq.km)","a3000",], scale=1, position="g-130.045/45.90+w8c/0.5c+h",)
fig.show()

```

---

<div class="post-metadata">

**Author:** ![weiji14](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/weiji14/32/33_2.png) [@weiji14](https://forum.generic-mapping-tools.org/u/weiji14)\
**Post date:** [June 4, 2022, 11:29am UTC](https://forum.generic-mapping-tools.org/t/how-represent-colour-bar-with-log-scale/2993/2 "2022-06-04T11:29:59Z")

</div>

Hi Adnan,

Looks like we haven’t aliased `log` to `Q` yet for colorbar, but try using `fig.colorbar(..., Q=True)`. Reference: [https://docs.generic-mapping-tools.org/6.3/colorbar.html#q](https://docs.generic-mapping-tools.org/6.3/colorbar.html#q).

Oh, and if you want the CPT to be log scale also, you can also do `pygmt.makecpt(..., log=True)` as per [https://www.pygmt.org/v0.6.1/api/generated/pygmt.makecpt.html](https://www.pygmt.org/v0.6.1/api/generated/pygmt.makecpt.html).

---

<div class="post-metadata">

**Author:** ![Adnan](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Adnan](https://forum.generic-mapping-tools.org/u/Adnan)\
**Post date:** [June 4, 2022, 12:27pm UTC](https://forum.generic-mapping-tools.org/t/how-represent-colour-bar-with-log-scale/2993/3 "2022-06-04T12:27:35Z")

</div>

Hi Weiji,  
Thanks for your useful comment. I have attempted with both approaches but none of them work, they output is just mask the whole figure as black layout. Is there any other way out for this.  
Thank you!

---

<div class="post-metadata">

**Author:** ![weiji14](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/weiji14/32/33_2.png) [@weiji14](https://forum.generic-mapping-tools.org/u/weiji14)\
**Post date:** [June 4, 2022, 1:59pm UTC](https://forum.generic-mapping-tools.org/t/how-represent-colour-bar-with-log-scale/2993/4 "2022-06-04T13:59:28Z")

</div>

Can you attach your figure (before and after the log scaling)? Just want to a see how it looks like.

---

<div class="post-metadata">

**Author:** ![Adnan](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@Adnan](https://forum.generic-mapping-tools.org/u/Adnan)\
**Post date:** [June 5, 2022, 1:04am UTC](https://forum.generic-mapping-tools.org/t/how-represent-colour-bar-with-log-scale/2993/5 "2022-06-05T01:04:12Z")

</div>

Hi Weiji,  
Here is the figure without log scaling

 ![Screenshot 2022-06-05 at 8.59.33 AM](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/5/5f05c1713d8dc27c2d484d8b4d439fc965338a95.png)

When i modify my make cpt with Q=true  
(below line)  
pygmt.makecpt(cmap=‘white,blue,red’,series=[0,15000,3000],continuous=True, Q=True)

the result will be like this.

 ![Screenshot 2022-06-05 at 9.01.19 AM](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/1/1667309c89a28a6ccd10c955a9f2410772c987d6.png)
