@@ -75,6 +75,7 @@ def sort_communities(consensus, communities):
7575def plot_mod_heatmap (data , communities , * , inds = None , edgecolor = 'black' ,
7676 ax = None , figsize = (6.4 , 4.8 ), xlabels = None , ylabels = None ,
7777 xlabelrotation = 90 , ylabelrotation = 0 , cbar = True ,
78+ square = True , ticklabels = None ,
7879 mask_diagonal = True , ** kwargs ):
7980 """
8081 Plots `data` as heatmap with borders drawn around `communities`
@@ -102,6 +103,10 @@ def plot_mod_heatmap(data, communities, *, inds=None, edgecolor='black',
102103 {x,y}labelrotation : float, optional
103104 Angle of the rotation of the labels. Available only if `{x,y}labels`
104105 provided. Default : xlabelrotation: 90, ylabelrotation: 0
106+ square : bool, optional
107+ Setting the matrix with equal aspect. Default: True
108+ ticklabels : list, optional
109+ List of labels for each area. Default: None
105110 cbar : bool, optional
106111 Whether to plot colorbar. Default: True
107112 mask_diagonal : bool, optional
@@ -132,6 +137,10 @@ def plot_mod_heatmap(data, communities, *, inds=None, edgecolor='black',
132137 coll = ax .pcolormesh (plot_data , edgecolor = 'none' , ** kwargs )
133138 ax .set (xlim = (0 , plot_data .shape [1 ]), ylim = (0 , plot_data .shape [0 ]))
134139
140+ # set equal aspect
141+ if square :
142+ ax .set_aspect ('equal' )
143+
135144 for side in ['top' , 'right' , 'left' , 'bottom' ]:
136145 ax .spines [side ].set_visible (False )
137146
@@ -179,6 +188,13 @@ def plot_mod_heatmap(data, communities, *, inds=None, edgecolor='black',
179188 ax .set_yticklabels (labels = ylabels , rotation = ylabelrotation )
180189 ax .tick_params (left = False , bottom = False )
181190
191+ if ticklabels is not None :
192+ labels_ind = [ticklabels [i ] for i in inds ]
193+ ax .set_xticks (np .arange (len (labels_ind ))+ 0.5 )
194+ ax .set_yticks (np .arange (len (labels_ind ))+ 0.5 )
195+ ax .set_xticklabels (labels_ind , rotation = 90 )
196+ ax .set_yticklabels (labels_ind )
197+
182198 return ax
183199
184200
0 commit comments