How to remove frame from matplotlib (pyplot.figure vs matplotlib.figure ) (frameon=False Problematic in matplotlib)

后端 未结 11 2135
猫巷女王i
猫巷女王i 2020-11-27 09:53

To remove frame in figure, I write

frameon=False

works perfect with pyplot.figure, but with matplotlib.Figure it

11条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 10:24

    ax.axis('off'), will as Joe Kington pointed out, remove everything except the plotted line.

    For those wanting to only remove the frame (border), and keep labels, tickers etc, one can do that by accessing the spines object on the axis. Given an axis object ax, the following should remove borders on all four sides:

    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)
    ax.spines['bottom'].set_visible(False)
    ax.spines['left'].set_visible(False)
    

    And, in case of removing x and y ticks from the plot:

     ax.get_xaxis().set_ticks([])
     ax.get_yaxis().set_ticks([])
    

提交回复
热议问题