-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfig_utils.py
58 lines (53 loc) · 1.9 KB
/
fig_utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""
Copyright © 2023 Howard Hughes Medical Institute, Authored by Carsen Stringer and Marius Pachitariu.
"""
import string
import matplotlib
import matplotlib.pyplot as plt
import matplotlib.transforms as mtransforms
import numpy as np
from matplotlib import rcParams
from matplotlib.colors import ListedColormap
default_font = 12
rcParams["font.family"] = "Arial"
rcParams["savefig.dpi"] = 300
rcParams["axes.spines.top"] = False
rcParams["axes.spines.right"] = False
rcParams["axes.titleweight"] = "normal"
rcParams["font.size"] = default_font
dcolors = np.array([[1,.5,.5], [.5,.5,1],[1,.75,.25], [.75, .75, .75], [.4, .4, .4]])
areas = ["V1", "CA1", "ephys"]
locmin = matplotlib.ticker.LogLocator(base=10.0,subs=np.arange(0.1, 1., 0.1),
numticks=10)
ltr = string.ascii_lowercase
fs_title = 16
weight_title = "normal"
def plot_label(ltr, il, ax, trans, fs_title=20):
ax.text(
0.0,
1.0,
ltr[il],
transform=ax.transAxes + trans,
va="bottom",
fontsize=fs_title,
fontweight="bold",
)
il += 1
return il
def conn_panel(ax, Aex, iplot, vmax=0.02, xt=-0.05, colorbar=True, title="sparse connectivity"):
ax.spines["bottom"].set_visible(False)
ax.spines["top"].set_visible(True)
im = ax.imshow(Aex[np.ix_(iplot, iplot)], cmap="bwr", vmin=-vmax, vmax=vmax)
# unicode arrow
ax.set_ylabel(r"$\leftarrow$ neurons")
ax.set_title(r"neurons $\rightarrow$", fontsize="medium", loc="center")
ax.set_xticks([])
ax.set_yticks([])
if colorbar:
cax = ax.inset_axes([1.05, 0.75, 0.05, 0.25])
cb = plt.colorbar(im, cax=cax)#, fontsize="small")
cb.ax.set_ylim(-vmax, vmax)
cb.set_ticks([-vmax, vmax])
cb.ax.tick_params(labelsize="small")
ax.text(xt, 1.32, title, transform=ax.transAxes,
ha="left", va="top", fontsize="large", fontstyle="italic")