# Replaced tick label in barplot

**URL:** <https://forum.generic-mapping-tools.org/t/replaced-tick-label-in-barplot/5014>\
**Category:** PyGMT Q&A\
**Created:** [June 24, 2024, 7:36pm UTC](https://forum.generic-mapping-tools.org/t/replaced-tick-label-in-barplot/5014 "2024-06-24T19:36:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Idontknow\_007](https://avatars.discourse-cdn.com/v4/letter/i/43a26b/32.png) [@Idontknow\_007](https://forum.generic-mapping-tools.org/u/Idontknow_007)\
**Post date:** [June 24, 2024, 7:36pm UTC](https://forum.generic-mapping-tools.org/t/replaced-tick-label-in-barplot/5014/1 "2024-06-24T19:36:04Z")

</div>

Hi,

```auto
fig = pygmt.Figure()

with fig.subplot(
    nrows=1,
    ncols=1,
    subsize=("15c", "10c"),
    frame=["WSne", "x+lPlace", "y+l# Fight"],     
    margins=["0.5c", "0.75c"],
):
    pen = "1.5p"

    with fig.set_panel(panel=0):
        fill = "blue"
        fig.basemap(region=[0, 4, 0, 15], frame="+t Tom vs Jerry")
        fig.plot(x=1+offset, y=10, style="b1c", fill=fill, pen=pen)
        fig.plot(x=1-offset, y=9, style="b1c", fill=colr,pen=pen)     
     
     
        fig.plot(x=3+offset, y=5, style="b1c", fill=fill, pen=pen, label="Tom")
        fig.plot(x=3-offset, y=12, style="b1c", fill=colr,pen=pen, label="Jerry")        
        fig.legend(position="JBL+jTR+o0.7c", box="+gwhite+pblack")     

fig.show()

```

How can I replaced the tick label to “Kithcen”, and “Backyard”.  
Also, how can I add grid lines.

Thank you!

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [June 24, 2024, 7:56pm UTC](https://forum.generic-mapping-tools.org/t/replaced-tick-label-in-barplot/5014/2 "2024-06-24T19:56:17Z")

</div>

you likely need this approach [4.3.8. Custom axes](https://docs.generic-mapping-tools.org/latest/reference/options.html#custom-axes)

---

<div class="post-metadata">

**Author:** ![Idontknow\_007](https://avatars.discourse-cdn.com/v4/letter/i/43a26b/32.png) [@Idontknow\_007](https://forum.generic-mapping-tools.org/u/Idontknow_007)\
**Post date:** [June 24, 2024, 9:26pm UTC](https://forum.generic-mapping-tools.org/t/replaced-tick-label-in-barplot/5014/3 "2024-06-24T21:26:27Z")

</div>

@mkononets thank you for the link. Do you have any suggestions or link on converting GMT to pygmt codes.

Thank you

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [June 24, 2024, 10:12pm UTC](https://forum.generic-mapping-tools.org/t/replaced-tick-label-in-barplot/5014/4 "2024-06-24T22:12:55Z")

</div>

[4.3.8. Custom axes example](https://docs.generic-mapping-tools.org/latest/reference/options.html#custom-axes) translated to `pygmt`

```auto
import pygmt

#The coord is the location of the desired annotation, tick, or grid-line,
#whereas type is a string composed of letters from
#a (annotation), i interval annotation, f frame tick, and g gridline.
#You must use either a or i within one file; no mixing is allowed.
#The coordinates should be arranged in increasing order. 
#If label is given it replaces the normal annotation based on the coord value.

xannots = '''416.0 ig Devonian
443.7 ig Silurian
488.3 ig Ordovician
542 ig Cambrian
'''
yannots = '''0 a
1 a
2 f
2.71828 ag e
3 f
3.1415926 ag @~p@~
4 f
5 f
6 f
6.2831852 ag 2@~p@~

'''

with open('xannots.txt', 'w') as f:
    f.writelines(xannots)

with open('yannots.txt', 'w') as f:
    f.writelines(yannots)

fig = pygmt.Figure()
region = '416/542/0/6.2831852'
projection = 'X-12c/6c'
frame = ['px25f5g25+u Ma', 'pycyannots.txt', 'sxcxannots.txt', 'WS+glightblue']
with pygmt.config(MAP_ANNOT_OFFSET_SECONDARY='10p', MAP_GRID_PEN_SECONDARY='2p'):
    fig.basemap(region=region, projection=projection, frame=frame)

fig.savefig('custom_axes.png', show=True)

```

 ![custom_axes](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/e/ec66a0179b1966ce028a3915efba66fa2de87f46.png)
