Setting `axes.linewidth` without changing the `rcParams` global dict

后端 未结 4 2031
有刺的猬
有刺的猬 2020-12-05 07:02

So, it seems one cannot do the following (it raises an error, since axes does not have a set_linewidth method):

axes_style = {\'lin         


        
4条回答
  •  既然无缘
    2020-12-05 07:35

    The above answer does not work, as it is explained in the comments. I suggest to use spines.

    import matplotlib.pyplot as plt
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    
    # you can change each line separately, like:
    #ax.spines['right'].set_linewidth(0.5)
    # to change all, just write:
    
    for axis in ['top','bottom','left','right']:
      ax.spines[axis].set_linewidth(0.5)
    
    plt.show()
    # see more about spines at:
    #http://matplotlib.org/api/spines_api.html
    #http://matplotlib.org/examples/pylab_examples/multiple_yaxis_with_spines.html
    

提交回复
热议问题