How to add black border to matplotlib 2.0 `ax` object In Python 3?

前端 未结 3 1541
别那么骄傲
别那么骄傲 2021-02-14 14:14

I\'ve been using style sheets in matplotlib lately. I really like how clean the seaborn-white looks and I want to be able to add the border to other s

3条回答
  •  萌比男神i
    2021-02-14 15:06

    You probably want ax.spines.set_color()

    These will give you a broad range of options for custom solutions:

    ax.spines['bottom'].set_color('0.5')
    ax.spines['top'].set_color(None)
    ax.spines['right'].set_color('0.5')
    ax.spines['left'].set_color(None)
    ax.patch.set_facecolor('0.1')
    plt.grid(b=True, which='major', color='0.2', linestyle='-')
    plt.grid(b=True, which='minor', color='0.2', linestyle='-')
    ax.tick_params(axis='x', colors='0.7', which='both')
    ax.tick_params(axis='y', colors='0.7', which='both')
    ax.yaxis.label.set_color('0.9')
    ax.xaxis.label.set_color('0.9')
    ax.margins(0.5)
    fig.patch.set_facecolor('0.15')
    

    For more details see: http://matplotlib.org/api/spines_api.html

提交回复
热议问题