comparison bin/spearman.py @ 33:317bf47b506c

generalise hist
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Tue, 22 Nov 2022 19:13:25 +0000
parents 91741bf3ab51
children 2e8002a64f72
comparison
equal deleted inserted replaced
32:91741bf3ab51 33:317bf47b506c
61 plt.axis([0,N-1,0.8,1.0]) 61 plt.axis([0,N-1,0.8,1.0])
62 plt.legend(loc='best') 62 plt.legend(loc='best')
63 plt.grid(True) 63 plt.grid(True)
64 plt.show(block=block) 64 plt.show(block=block)
65 65
66 def hist(): 66 def hist_x():
67 sdd=[(i,xm-(i*xsd)) for i in range(-2,3)] 67 hist(xm,xsd,[xd[i].mean for i in range(N)],
68 'Mean of rank correlation of each segment x all other segments')
69
70 def hist_all():
71 hist(all_m,np.sqrt(all_s.variance),all,
72 'Rank correlation of each segment x whole crawl')
73
74 def hist(m,sd,hh,title):
75 sdd=[(i,m-(i*sd)) for i in range(-2,3)]
68 fig,hax=plt.subplots() # Thanks to https://stackoverflow.com/a/7769497 76 fig,hax=plt.subplots() # Thanks to https://stackoverflow.com/a/7769497
69 sdax=hax.twiny() 77 sdax=hax.twiny()
70 hax.hist([xd[i].mean for i in range(N)],color='lightblue') 78 hax.hist(hh,color='lightblue')
71 hax.set_title('Mean of rank correlation of each segment x all other segments') 79 hax.set_title(title)
72 for s,v in sdd: 80 for s,v in sdd:
73 sdax.plot([v,v],[0,18],'b') 81 sdax.plot([v,v],[0,18],'b')
74 sdax.set_xlim(hax.get_xlim()) 82 sdax.set_xlim(hax.get_xlim())
75 sdax.set_ylim(hax.get_ylim()) 83 sdax.set_ylim(hax.get_ylim())
76 sdax.set_xticks([v for s,v in sdd]) 84 sdax.set_xticks([v for s,v in sdd])