Skip to content

Commit 692cd91

Browse files
improving cumulative plot
1 parent f3eaec0 commit 692cd91

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • visual_behavior/dimensionality_reduction/clustering

visual_behavior/dimensionality_reduction/clustering/plotting.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,11 +1231,14 @@ def get_cluster_color_map(labels):
12311231

12321232
def plot_N_clusters_by_cre_line(labels_cre, ax=None, palette=None):
12331233
if ax is None:
1234-
fig, ax = plt.subplots(1, 1, figsize=(7, 7))
1234+
fig, ax = plt.subplots(1, 1, figsize=(6, 3))
1235+
12351236
if palette is None:
12361237
palette = [(1.0, 0.596078431372549, 0.5882352941176471),
12371238
(0.6196078431372549, 0.8549019607843137, 0.8980392156862745),
12381239
(0.7725490196078432, 0.6901960784313725, 0.8352941176470589)]
1240+
markersize = [14, 10, 10]
1241+
linewidth = [4, 2, 2]
12391242
for i, cre_line in enumerate(labels_cre.keys()):
12401243
labels = labels_cre[cre_line]
12411244
(unique, counts) = np.unique(labels, return_counts=True)
@@ -1244,11 +1247,14 @@ def plot_N_clusters_by_cre_line(labels_cre, ax=None, palette=None):
12441247
cumulative_sum = [0]
12451248
for freq in frequencies:
12461249
cumulative_sum.append(cumulative_sum[-1] + freq)
1247-
ax.grid()
1250+
12481251
ax.plot(range(0, len(cumulative_sum)), cumulative_sum, 'o-', color=palette[i],
1249-
linewidth=4, markersize=10)
1252+
linewidth=linewidth[i], markersize=markersize[i])
1253+
ax.hlines(y=80, xmin=-0.5, xmax=11, linestyle='--', color='Grey')
1254+
ax.set_xlim([-0.5, 11])
1255+
ax.set_xticks(np.arange(0, len(cumulative_sum)))
12501256
ax.set_xlabel('Cluster number')
1251-
ax.set_ylabel('Cells per cluster (%)')
1257+
ax.set_ylabel('Cumulative % of all cells')
12521258
ax.legend(['Excitatory', 'SST inhibitory', 'VIP inhibitory'])
12531259

12541260
return ax

0 commit comments

Comments
 (0)