matplotlib去掉边框
matplotlib去掉边框
一、总结
一句话总结:
去掉上边框:ax.spines['top'].set_visible(False)
fig, ax = plt.subplots() # 取消边框 for key, spine in ax.spines.items(): # 'left', 'right', 'bottom', 'top' if key == 'left' or key == 'right': spine.set_visible(False)
二、matplotlib去掉边框
import numpy as np import matplotlib.pyplot as plt fig, ax = plt.subplots() # 取消边框 for key, spine in ax.spines.items(): # 'left', 'right', 'bottom', 'top' if key == 'left' or key == 'right': spine.set_visible(False) plt.xticks([]) plt.yticks([]) x=[1,2,3,4,5] y=[4,9,6,8,3] plt.plot(x,y,'ro') plt.plot(x,y,'k--') plt.show()