Search code examples
pythonmatplotlibcolorsfigure

Is there a way to change the alpha value of the x/y ticks in matplotlib?


I am wanting to change the alpha value of the color of the x ticks. I understand how to change the color of the xticks (see below), but am not sure how to change the alpha value. Is this possible? Any help would be much appreciated.

ax.tick_params(axis='x', which=u'both',length=3, color="red")

Thanks in advance.


Solution

  • You can pass a 4-tuple, where the last one represents alpha channel:

    ax.tick_params(axis='x', which=u'both',length=3, color=[1,0,0,0.5])
    

    Or you can pass a hex code:

    ax.tick_params(axis='x', which=u'both',length=5, color='#FF000080')
    

    Output:

    enter image description here