How to draw a frame on a matplotlib figure

前端 未结 2 698
被撕碎了的回忆
被撕碎了的回忆 2021-02-09 18:58

I want to show the frame in this figure. I tried running the code below but it didnt work :

ax = self.canvas.figure.add_subplot(111)
ax.spines[\'top\'].set_vis         


        
2条回答
  •  时光取名叫无心
    2021-02-09 19:40

    The borders (or spines) are already visible, but white. You need to change the color as explained in this response: https://stackoverflow.com/a/43265998/1773344

    example for some kind of gray:

    ax.spines['bottom'].set_color('0.5')
    ax.spines['top'].set_color('0.5')
    ax.spines['right'].set_color('0.5')
    ax.spines['left'].set_color('0.5')
    

    If you want the borders AROUND the axes, there is no simple solution. Except perhaps putting your axis inside an axis with adjusted borders as partially explained in this answer: https://stackoverflow.com/a/22608025/1773344

提交回复
热议问题