fig6.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. """Figure 6 plots, use run -i fig6.py"""
  2. allmseustrs = np.union1d(mvimseustrs, grtmseustrs)
  3. modis = ['fmi', 'rmi', 'suppressionrmi', 'feedbackrmi', 'runfmi', 'sitfmi']
  4. mi = pd.MultiIndex.from_product([allmseustrs, STIMTYPES, modis],
  5. names=['mseu', 'stimtype', 'mi'])
  6. columns = ['meanrate', 'meanburstratio', 'spars', 'rel', 'meanpkw', 'snr']
  7. fig6 = pd.DataFrame(index=mi, columns=columns)
  8. # redefine these here, in case saved data was loaded from pickles and these definitions
  9. # later in calc.py were therefore skipped:
  10. stimtype2FMI = {'mvi': mviFMI, 'grt': grtFMI}
  11. stimtype2RMI = {'mvi': mviRMI, 'grt': grtRMI}
  12. loss = 'soft_l1' # loss function, less sensitive to outliers than ordinary least squares
  13. f_scale = 0.25 # residual value at which to start treating points as outliers
  14. # scatter and dumbbell plot run modulation index for feedback vs. suppression trials,
  15. # for movies and gratings, for all measures:
  16. figsize = DEFAULTFIGURESIZE
  17. linmin, linmax, linstep = -1, 1, 1
  18. ticks = np.arange(linmin, linmax+linstep, linstep)
  19. for measure in modmeasuresnoblank:
  20. axislabel = measure2axislabel[measure]
  21. axislabel = short2longaxislabel.get(axislabel, axislabel)
  22. if axislabel.islower():
  23. axislabel = axislabel.capitalize()
  24. for stimtype in STIMTYPES:
  25. FMI = stimtype2FMI[stimtype]
  26. RMI = stimtype2RMI[stimtype]
  27. mseustrs = {'mvi':mvimseustrs, 'grt':grtmseustrs}[stimtype]
  28. mseu2exmpli = {'mvi':mvimseu2exmpli, 'grt':grtmseu2exmpli}[stimtype]
  29. stimtypelabel = stimtype2axislabel[stimtype]
  30. supprmis, fbrmis, exmplis, exmplmseustrs, normlis = [], [], [], [], []
  31. keptmseui = 0 # manually init and increment instead of using enumerate()
  32. for mseustr in mseustrs:
  33. supprmi = RMI[measure][mseustr, True]
  34. fbrmi = RMI[measure][mseustr, False]
  35. if np.isnan(supprmi) or np.isnan(fbrmi): # missing one or both mod values
  36. continue
  37. supprmis.append(supprmi)
  38. fbrmis.append(fbrmi)
  39. fig6.loc[mseustr, stimtype, 'suppressionrmi'][measure] = supprmi
  40. fig6.loc[mseustr, stimtype, 'feedbackrmi'][measure] = fbrmi
  41. if mseustr in mseu2exmpli:
  42. exmplis.append(keptmseui)
  43. exmplmseustrs.append(mseustr)
  44. else:
  45. normlis.append(keptmseui)
  46. keptmseui += 1 # manually increment
  47. supprmis = np.asarray(supprmis)
  48. fbrmis = np.asarray(fbrmis)
  49. if len(supprmis) == 0 or len(fbrmis) == 0:
  50. continue # nothing to plot
  51. f, a = plt.subplots(figsize=figsize)
  52. ## scatter plot feedback vs suppression RMI
  53. wintitle('fbsupp RMI %s %s' % (measure, stimtypelabel))
  54. # plot x=0 and y=0 lines:
  55. a.axhline(y=0, ls='--', marker='', color='lightgray', zorder=-np.inf)
  56. a.axvline(x=0, ls='--', marker='', color='lightgray', zorder=-np.inf)
  57. # plot y=x line:
  58. xyline = [linmin, linmax], [linmin, linmax]
  59. a.plot(xyline[0], xyline[1], '--', color='gray', zorder=-1)
  60. # plot normal (non-example) points:
  61. a.scatter(supprmis[normlis], fbrmis[normlis], clip_on=False,
  62. marker='.', c='None', edgecolor='black', s=DEFSZ)
  63. # plot example points, one at a time:
  64. for exmpli, mseustr in zip(exmplis, exmplmseustrs):
  65. marker = exmpli2mrk[mseu2exmpli[mseustr]]
  66. c = exmpli2clr[mseu2exmpli[mseustr]]
  67. sz = exmpli2sz[mseu2exmpli[mseustr]]
  68. lw = exmpli2lw[mseu2exmpli[mseustr]]
  69. a.scatter(supprmis[exmpli], fbrmis[exmpli], clip_on=False,
  70. marker=marker, c=c, s=sz, lw=lw)
  71. # get fname for relevant figure panels:
  72. relev_measures = ['meanrate', 'meanburstratio', 'spars', 'rel']
  73. if (measure in relev_measures) and stimtype == 'mvi':
  74. # if measure is relevant, get parameters for model from csv file:
  75. if measure == 'meanrate':
  76. fname = os.path.join('stats', 'figure_6a1_coefs.csv')
  77. elif measure == 'meanburstratio':
  78. fname = os.path.join('stats', 'figure_6a2_coefs.csv')
  79. elif measure == 'spars':
  80. fname = os.path.join('stats', 'figure_6a3_coefs.csv')
  81. elif measure == 'rel':
  82. fname = os.path.join('stats', 'figure_6a4_coefs.csv')
  83. try:
  84. df = pd.read_csv(fname)
  85. foundregression = True
  86. except FileNotFoundError:
  87. print('Missing file: %s' % fname)
  88. foundregression = False
  89. if foundregression:
  90. df = pd.read_csv(fname)
  91. mm = df['slope'][0]
  92. b = df['intercept'][0]
  93. x = np.array([np.nanmin(supprmis), np.nanmax(supprmis)])
  94. y = mm * x + b
  95. a.plot(x, y, '-', color='red') # plot linregress fit
  96. '''
  97. else:
  98. # calc/plot linregress line:
  99. # exclude extreme +/- 1 FMI and RMI values from linregress:
  100. non1is = (abs(supprmis) != 1) & (abs(fbrmis) != 1)
  101. supprmisnon1 = supprmis[non1is]
  102. fbrmisnon1 = fbrmis[non1is]
  103. # robust least squares:
  104. result = least_squares(linear_loss, (0, 0), args=(supprmisnon1, fbrmisnon1),
  105. loss=loss, f_scale=f_scale)
  106. mm, b = result['x']
  107. residuals = result['fun']
  108. #rsq = residual_rsquared(fbrmisnon1, residuals)
  109. #mm, b, rr, p, stderr = linregress(rmisnon1, fmisnon1)
  110. #rsq = rr * rr
  111. x = np.array([supprmisnon1.min(), supprmisnon1.max()])
  112. '''
  113. #a.set_title('%s RMI' % axislabel) # typeface too big by default, decreases panel size
  114. a.set_xlabel('Suppression')
  115. a.set_ylabel('Feedback')
  116. a.set_xlim(linmin, linmax)
  117. a.set_ylim(linmin, linmax)
  118. a.set_xticks(ticks)
  119. a.set_yticks(a.get_xticks()) # make log scale y ticks the same as x ticks
  120. a.minorticks_off()
  121. a.set_aspect('equal')
  122. a.spines['left'].set_position(('outward', 4))
  123. a.spines['bottom'].set_position(('outward', 4))
  124. #txt = ('$\mathregular{R^{2}=%.2g}$' % rsq)
  125. #.add_artist(AnchoredText(txt, loc='lower right', frameon=False))
  126. #txt = ('$\mathregular{p=%.2g}$\n'
  127. # '$\mathregular{R^{2}=%.2g}$' % (p, rsq)) # prob that slope is 0
  128. #a.add_artist(AnchoredText(txt, loc='upper left', frameon=False))
  129. ## dumbbell plot feedback vs suppression RMI
  130. '''
  131. f, a = plt.subplots(figsize=DUMBBELLFIGSIZE)
  132. wintitle('fbsupp RMI dumbbell %s %s' % (measure, stimtypelabel))
  133. # plot x=0 line:
  134. a.axvline(x=0, ls='--', marker='', color='lightgray', zorder=-np.inf)
  135. # plot horizontal lines:
  136. sortis = fbrmis.argsort() # y vals for hlines
  137. npairs = len(fbrmis)
  138. ys = np.arange(npairs)
  139. srtdfbrmis, srtdsupprmis = fbrmis[sortis], supprmis[sortis]
  140. a.hlines(ys, srtdfbrmis, srtdsupprmis, zorder=-100)
  141. sz = 50
  142. # plot supprmis points:
  143. a.scatter(srtdsupprmis, ys, marker='.', c='white', edgecolor='black', s=sz)
  144. # plot fbrmis points:
  145. a.scatter(srtdfbrmis, ys, marker='.', c='black', s=sz)
  146. a.set_xlabel('%s RMI' % axislabel)
  147. a.set_ylabel('Neurons')
  148. a.set_xlim(linmin, linmax)
  149. a.set_xticks(ticks)
  150. a.set_yticks([])
  151. '''
  152. # scatter plot feedback modulation index for run vs. sit trials,
  153. # for movies and gratings, for all measures:
  154. figsize = DEFAULTFIGURESIZE
  155. linmin, linmax, linstep = -1, 1, 1
  156. ticks = np.arange(linmin, linmax+linstep, linstep)
  157. for measure in modmeasuresnoblank:
  158. axislabel = measure2axislabel[measure]
  159. if axislabel.islower():
  160. axislabel = axislabel.capitalize()
  161. for stimtype in STIMTYPES:
  162. FMI = stimtype2FMI[stimtype]
  163. mseustrs = {'mvi':mvimseustrs, 'grt':grtmseustrs}[stimtype]
  164. mseu2exmpli = {'mvi':mvimseu2exmpli, 'grt':grtmseu2exmpli}[stimtype]
  165. stimtypelabel = stimtype2axislabel[stimtype]
  166. runfmis, sitfmis, exmplis, exmplmseustrs, normlis = [], [], [], [], []
  167. keptmseui = 0 # manually init and increment instead of using enumerate()
  168. for mseustr in mseustrs:
  169. runfmi = FMI[measure][mseustr, 'run']
  170. sitfmi = FMI[measure][mseustr, 'sit']
  171. if np.isnan(runfmi) or np.isnan(sitfmi): # missing one or both mod values
  172. continue
  173. runfmis.append(runfmi)
  174. sitfmis.append(sitfmi)
  175. fig6.loc[mseustr, stimtype, 'runfmi'][measure] = runfmi
  176. fig6.loc[mseustr, stimtype, 'sitfmi'][measure] = sitfmi
  177. if mseustr in mseu2exmpli:
  178. exmplis.append(keptmseui)
  179. exmplmseustrs.append(mseustr)
  180. else:
  181. normlis.append(keptmseui)
  182. keptmseui += 1 # manually increment
  183. runfmis = np.asarray(runfmis)
  184. sitfmis = np.asarray(sitfmis)
  185. if len(runfmis) == 0 or len(sitfmis) == 0:
  186. continue # nothing to plot
  187. f, a = plt.subplots(figsize=figsize)
  188. wintitle('runsit FMI %s %s' % (measure, stimtypelabel))
  189. # plot x=0 and y=0 lines:
  190. a.axhline(y=0, ls='--', marker='', color='lightgray', zorder=-np.inf)
  191. a.axvline(x=0, ls='--', marker='', color='lightgray', zorder=-np.inf)
  192. # plot y=x line:
  193. xyline = [linmin, linmax], [linmin, linmax]
  194. a.plot(xyline[0], xyline[1], '--', color='gray', zorder=-1)
  195. # plot normal (non-example) points:
  196. a.scatter(sitfmis[normlis], runfmis[normlis], clip_on=False,
  197. marker='.', c='None', edgecolor='black', s=DEFSZ)
  198. # plot example points, one at a time:
  199. for exmpli, mseustr in zip(exmplis, exmplmseustrs):
  200. marker = exmpli2mrk[mseu2exmpli[mseustr]]
  201. c = exmpli2clr[mseu2exmpli[mseustr]]
  202. sz = exmpli2sz[mseu2exmpli[mseustr]]
  203. lw = exmpli2lw[mseu2exmpli[mseustr]]
  204. a.scatter(sitfmis[exmpli], runfmis[exmpli], clip_on=False,
  205. marker=marker, c=c, s=sz, lw=lw)
  206. # get fname for relevant figure panels:
  207. if stimtype == 'mvi':
  208. relev_measures = ['meanrate', 'meanburstratio', 'spars', 'rel']
  209. elif stimtype == 'grt':
  210. relev_measures = ['meanrate', 'meanburstratio']
  211. if measure in relev_measures:
  212. # if measure is relevant, get parameters for model from csv file:
  213. if stimtype == 'mvi':
  214. if measure == 'meanrate':
  215. fname = os.path.join('stats', 'figure_6b1_coefs.csv')
  216. elif measure == 'meanburstratio':
  217. fname = os.path.join('stats', 'figure_6b2_coefs.csv')
  218. elif measure == 'spars':
  219. fname = os.path.join('stats', 'figure_6b3_coefs.csv')
  220. elif measure == 'rel':
  221. fname = os.path.join('stats', 'figure_6b4_coefs.csv')
  222. elif stimtype == 'grt':
  223. if measure == 'meanrate':
  224. fname = os.path.join('stats', 'figure_6_S1b1_coefs.csv')
  225. elif measure == 'meanburstratio':
  226. fname = os.path.join('stats', 'figure_6_S1b2_coefs.csv')
  227. try:
  228. df = pd.read_csv(fname)
  229. foundregression = True
  230. except FileNotFoundError:
  231. print('Missing file: %s' % fname)
  232. foundregression = False
  233. if foundregression:
  234. df = pd.read_csv(fname)
  235. mm = df['slope'][0]
  236. b = df['intercept'][0]
  237. x = np.array([np.nanmin(sitfmis), np.nanmax(sitfmis)])
  238. y = mm * x + b
  239. a.plot(x, y, '-', color='red') # plot linregress fit
  240. '''
  241. else:
  242. # calc/plot linregress line:
  243. # exclude extreme +/- 1 FMI values from linregress:
  244. non1is = (abs(sitfmis) != 1) & (abs(runfmis) != 1)
  245. runfmisnon1 = runfmis[non1is]
  246. sitfmisnon1 = sitfmis[non1is]
  247. # robust least squares:
  248. result = least_squares(linear_loss, (0, 0), args=(sitfmisnon1, runfmisnon1),
  249. loss=loss, f_scale=f_scale)
  250. mm, b = result['x']
  251. residuals = result['fun']
  252. #rsq = residual_rsquared(runfmisnon1, residuals)
  253. #mm, b, rr, p, stderr = linregress(sitfmisnon1, runfmisnon1)
  254. #rsq = rr * rr
  255. x = np.array([sitfmisnon1.min(), sitfmisnon1.max()])
  256. '''
  257. #a.set_title('%s FMI' % axislabel) # typeface too big by default, decreases panel size
  258. a.set_xlabel('Sit')
  259. a.set_ylabel('Run')
  260. a.set_xlim(linmin, linmax)
  261. a.set_ylim(linmin, linmax)
  262. a.set_xticks(ticks)
  263. a.set_yticks(a.get_xticks()) # make log scale y ticks the same as x ticks
  264. a.minorticks_off()
  265. a.set_aspect('equal')
  266. a.spines['left'].set_position(('outward', 4))
  267. a.spines['bottom'].set_position(('outward', 4))
  268. #txt = ('$\mathregular{R^{2}=%.2g}$' % rsq)
  269. #a.add_artist(AnchoredText(txt, loc='lower right', frameon=False))
  270. #txt = ('$\mathregular{p=%.2g}$\n'
  271. # '$\mathregular{R^{2}=%.2g}$' % (p, rsq)) # prob that slope is 0
  272. #a.add_artist(AnchoredText(txt, loc='upper left', frameon=False))
  273. ## dumbbell plot run vs sit FMI
  274. '''
  275. f, a = plt.subplots(figsize=DUMBBELLFIGSIZE)
  276. wintitle('runsit FMI dumbbell %s %s' % (measure, stimtypelabel))
  277. # plot x=0 line:
  278. a.axvline(x=0, ls='--', marker='', color='lightgray', zorder=-np.inf)
  279. # plot horizontal lines:
  280. sortis = runfmis.argsort() # y vals for hlines
  281. npairs = len(runfmis)
  282. ys = np.arange(npairs)
  283. srtdrunfmis, srtdsitfmis = runfmis[sortis], sitfmis[sortis]
  284. a.hlines(ys, srtdrunfmis, srtdsitfmis, zorder=-100)
  285. sz = 50
  286. # plot sitfmis points:
  287. a.scatter(srtdsitfmis, ys, marker='.', c='white', edgecolor='black', s=sz)
  288. # plot runfmis points:
  289. a.scatter(srtdrunfmis, ys, marker='.', c='black', s=sz)
  290. a.set_xlabel('%s FMI' % short2longaxislabel.get(axislabel, axislabel))
  291. a.set_ylabel('Neurons')
  292. a.set_xlim(linmin, linmax)
  293. a.set_xticks(ticks)
  294. a.set_yticks([])
  295. '''
  296. # scatter plot feedback modulation index vs. run modulation index,
  297. # for movies and gratings, for all measures:
  298. figsize = DEFAULTFIGURESIZE
  299. linmin, linmax, linstep = -1, 1, 1
  300. ticks = np.arange(linmin, linmax+linstep, linstep)
  301. for measure in modmeasuresnoblank:
  302. axislabel = measure2axislabel[measure]
  303. if axislabel.islower():
  304. axislabel = axislabel.capitalize()
  305. for stimtype in STIMTYPES:
  306. FMI = stimtype2FMI[stimtype]
  307. RMI = stimtype2RMI[stimtype]
  308. mseustrs = {'mvi':mvimseustrs, 'grt':grtmseustrs}[stimtype]
  309. mseu2exmpli = {'mvi':mvimseu2exmpli, 'grt':grtmseu2exmpli}[stimtype]
  310. stimtypelabel = stimtype2axislabel[stimtype]
  311. fmis, rmis, exmplis, exmplmseustrs, normlis = [], [], [], [], []
  312. keptmseui = 0 # manually init and increment instead of using enumerate()
  313. for mseustr in mseustrs:
  314. fmi = FMI[measure][mseustr, 'none'] # ignore run condition for FMI
  315. """
  316. TODO: plot RMI calc'd across both opto conditions, but before doing that, you
  317. have to normalize by the relative mean measure (say rate) of the two opto
  318. conditions, and weight them appropriately, says Jackson Smith from Oxford. Should
  319. really do the equivalent for FMI, especially cuz there are not equal numbers of
  320. trials for run vs sit, but the analysis that plots FMI as a function of run vs sit
  321. trials more or less shows that you can pool across run condition to calculate FMI
  322. """
  323. rmi = RMI[measure][mseustr, False] # use only feedback condition for RMI
  324. if np.isnan(fmi) or np.isnan(rmi): # missing one or both mod values
  325. continue
  326. fmis.append(fmi)
  327. rmis.append(rmi)
  328. fig6.loc[mseustr, stimtype, 'fmi'][measure] = fmi
  329. fig6.loc[mseustr, stimtype, 'rmi'][measure] = rmi
  330. if mseustr in mseu2exmpli:
  331. exmplis.append(keptmseui)
  332. exmplmseustrs.append(mseustr)
  333. else:
  334. normlis.append(keptmseui)
  335. keptmseui += 1 # manually increment
  336. fmis = np.asarray(fmis)
  337. rmis = np.asarray(rmis)
  338. if len(fmis) == 0 or len(rmis) == 0:
  339. continue # nothing to plot
  340. f, a = plt.subplots(figsize=figsize)
  341. wintitle('FMI vs RMI %s %s none False' % (measure, stimtypelabel))
  342. # plot x=0 and y=0 lines:
  343. a.axhline(y=0, ls='--', marker='', color='lightgray', zorder=-np.inf)
  344. a.axvline(x=0, ls='--', marker='', color='lightgray', zorder=-np.inf)
  345. # plot y=x line:
  346. xyline = [linmin, linmax], [linmin, linmax]
  347. a.plot(xyline[0], xyline[1], '--', color='gray', zorder=-1)
  348. # plot normal (non-example) points:
  349. a.scatter(rmis[normlis], fmis[normlis], clip_on=False,
  350. marker='.', c='None', edgecolor='black', s=DEFSZ)
  351. # plot example points, one at a time:
  352. for exmpli, mseustr in zip(exmplis, exmplmseustrs):
  353. marker = exmpli2mrk[mseu2exmpli[mseustr]]
  354. c = exmpli2clr[mseu2exmpli[mseustr]]
  355. sz = exmpli2sz[mseu2exmpli[mseustr]]
  356. lw = exmpli2lw[mseu2exmpli[mseustr]]
  357. a.scatter(rmis[exmpli], fmis[exmpli], clip_on=False,
  358. marker=marker, c=c, s=sz, lw=lw)
  359. # get fname for relevant figure panels:
  360. if stimtype == 'mvi':
  361. relev_measures = ['meanrate', 'meanburstratio', 'spars', 'rel']
  362. elif stimtype == 'grt':
  363. relev_measures = ['meanrate', 'meanburstratio']
  364. if measure in relev_measures:
  365. # if measure is relevant, get parameters for model from csv file:
  366. if stimtype == 'mvi':
  367. if measure == 'meanrate':
  368. fname = os.path.join('stats', 'figure_6c1_coefs.csv')
  369. elif measure == 'meanburstratio':
  370. fname = os.path.join('stats', 'figure_6c2_coefs.csv')
  371. elif measure == 'spars':
  372. fname = os.path.join('stats', 'figure_6c3_coefs.csv')
  373. elif measure == 'rel':
  374. fname = os.path.join('stats', 'figure_6c4_coefs.csv')
  375. elif stimtype == 'grt':
  376. if measure == 'meanrate':
  377. fname = os.path.join('stats', 'figure_6_S1c1_coefs.csv')
  378. elif measure == 'meanburstratio':
  379. fname = os.path.join('stats', 'figure_6_S1c2_coefs.csv')
  380. try:
  381. df = pd.read_csv(fname)
  382. foundregression = True
  383. except FileNotFoundError:
  384. print('Missing file: %s' % fname)
  385. foundregression = False
  386. if foundregression:
  387. df = pd.read_csv(fname)
  388. mm = df['slope'][0]
  389. b = df['intercept'][0]
  390. x = np.array([np.nanmin(rmis), np.nanmax(rmis)])
  391. y = mm * x + b
  392. a.plot(x, y, '-', color='red') # plot linregress fit
  393. '''
  394. else:
  395. # calc/plot linregress line:
  396. # exclude extreme +/- 1 FMI and RMI values from linregress:
  397. non1is = (abs(rmis) != 1) & (abs(fmis) != 1)
  398. rmisnon1 = rmis[non1is]
  399. fmisnon1 = fmis[non1is]
  400. # robust least squares:
  401. result = least_squares(linear_loss, (0, 0), args=(rmisnon1, fmisnon1),
  402. loss=loss, f_scale=f_scale)
  403. mm, b = result['x']
  404. residuals = result['fun']
  405. rsq = residual_rsquared(fmisnon1, residuals)
  406. mm, b, rr, p, stderr = linregress(rmisnon1, fmisnon1)
  407. rsq = rr * rr
  408. x = np.array([rmisnon1.min(), rmisnon1.max()])
  409. '''
  410. #a.set_title('%s' % axislabel) # typeface too big by default, decreases panel size
  411. a.set_xlabel('RMI')
  412. a.set_ylabel('FMI')
  413. a.set_xlim(linmin, linmax)
  414. a.set_ylim(linmin, linmax)
  415. a.set_xticks(ticks)
  416. a.set_yticks(a.get_xticks())
  417. a.minorticks_off()
  418. a.set_aspect('equal')
  419. a.spines['left'].set_position(('outward', 4))
  420. a.spines['bottom'].set_position(('outward', 4))
  421. #txt = ('$\mathregular{R^{2}=%.2g}$' % rsq)
  422. #a.add_artist(AnchoredText(txt, loc='lower right', frameon=False))
  423. #txt = ('$\mathregular{p=%.2g}$\n'
  424. # '$\mathregular{R^{2}=%.2g}$' % (p, rsq)) # prob that slope is 0
  425. #a.add_artist(AnchoredText(txt, loc='upper left', frameon=False))