matplotlib的boxplot上画横线
1 import matplotlib.pyplot as plt 2 import numpy as np 3 4 # Generate some data... 5 data = np.random.random((100, 1)) 6 # y = data.mean(axis=0) 7 # x = np.random.random(y.size) * 10 8 # x -= x.min() 9 # x.sort() 10 11 # Plot a line between the means of each dataset 12 # plt.plot(x, y, 'b-') 13 14 # Save the default tick positions, so we can reset them... 15 # locs, labels = plt.xticks() 16 17 # boxplot 18 plt.boxplot(data)#, positions=x, notch=True) 19 20 # horizontal line plot 21 axes = plt.gca() 22 left, right = axes.get_xlim() 23 axes.hlines(y=0.5, xmin=left, xmax=right, linestyles='dashed') 24 25 # Reset the xtick locations. 26 # plt.xticks(locs) 27 plt.show()
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步