Search code examples
pythonmatplotlibaxes

Matplotlib: How to change de color and width of axes


I would like to change the color or the width of the axes of a plot.

For example, from this: First image

I would like to get: Final image

Is it possible?

Thanks


Solution

  • You can use the spines attribute of your axis:

    f, ax = plt.subplots(1)
    
    for side in ax.spines.keys():  # 'top', 'bottom', 'left', 'right'
        ax.spines[side].set_linewidth(5)
    
    plt.plot(numpy.arange(10))
    plt.show()