Remove colorbar ticks and labels


I would like to remove colorbar labels and ticks.

def plot_something(fig, panel):

     region = [131.29, 150.89, 34.02, 50.77]
    with fig.set_panel(panel=panel):    
        fig.basemap(region=region, projection="M?", panel=panel)
        fig.coast(land="grey", projection="M?", region=region, panel=panel, water="white")
    return fig

with fig.subplot(
    figsize=("15c", "6c"),
    frame=["af", "WSne"],
    plot_something(fig, panel=[0])
    plot_something(fig, panel=[1])   

fig.colorbar(cmap="polar", frame=["af", "y+lX", "wesn"], position="JBC+w6c/0.5c")


How can I remove all ticks from the colorbar? I removed the colorbar range labels using “wesn” in fig.colorbar() but that doesn’t seem like the proper way to do it.

Note that the polar colormap is not showing any data here, this was just for MWE purposes.

Any help would be much appreciated!

For frame, adding a in the argument adds major ticks and annotations and adding f adds minor ticks. So if you were to not want any annotations or ticks, you would just leave those options out of your argument to the frame parameter:

fig.colorbar(cmap="polar", frame=["y+lX"], position="JBC+w6c/0.5c")

If you were to want annotations but not ticks, you could set the tick length to 0:

with pygmt.config(MAP_TICK_LENGTH=0):
    fig.colorbar(cmap="polar", frame=["a","y+lX"], position="JBC+w6c/0.5c") 
1 Like

Thank you so much!