- 散点图,每个bin 中画一段线
from scipy import stats
bins=[3.5,4,4.5,5,5.5,6,6.5]
x,y=L_shell,ne
plt.scatter(x,y,s=25,c='b')
bin_medians, bin_edges, binnumber = stats.binned_statistic(x,y,statistic='median', bins=bins)
plt.hlines(bin_medians,bin_edges[:-1],bin_edges[1:],label='median')
for i in range(len(bin_medians)):
xvar=[bin_edges[i],bin_edges[i+1]]
yvar=[bin_medians[i],bin_medians[i]]
plt.plot(xvar,yvar,'-',color='red')
网友评论