@@ -75,7 +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 ,
78+ square = True , xticklabels = None , yticklabels = None ,
7979 mask_diagonal = True , ** kwargs ):
8080 """
8181 Plots `data` as heatmap with borders drawn around `communities`
@@ -105,8 +105,9 @@ def plot_mod_heatmap(data, communities, *, inds=None, edgecolor='black',
105105 provided. Default : xlabelrotation: 90, ylabelrotation: 0
106106 square : bool, optional
107107 Setting the matrix with equal aspect. Default: True
108- ticklabels : list, optional
109- List of labels for each area. Default: None
108+ {x,y}ticklabels : list, optional
109+ Incompatible with `{x,y}labels`. List of labels for each entry (not
110+ community) in `data`. Default: None
110111 cbar : bool, optional
111112 Whether to plot colorbar. Default: True
112113 mask_diagonal : bool, optional
@@ -120,6 +121,10 @@ def plot_mod_heatmap(data, communities, *, inds=None, edgecolor='black',
120121 Axis object containing plot
121122 """
122123
124+ for t , l in zip ([xticklabels , yticklabels ], [xlabels , ylabels ]):
125+ if t is not None and l is not None :
126+ raise ValueError ('Cannot set both {x,y}labels and {x,y}ticklabels' )
127+
123128 # get indices for sorting consensus
124129 if inds is None :
125130 inds = sort_communities (data , communities )
@@ -188,11 +193,13 @@ def plot_mod_heatmap(data, communities, *, inds=None, edgecolor='black',
188193 ax .set_yticklabels (labels = ylabels , rotation = ylabelrotation )
189194 ax .tick_params (left = False , bottom = False )
190195
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 )
196+ if xticklabels is not None :
197+ labels_ind = [xticklabels [i ] for i in inds ]
198+ ax .set_xticks (np .arange (len (labels_ind )) + 0.5 )
195199 ax .set_xticklabels (labels_ind , rotation = 90 )
200+ if yticklabels is not None :
201+ labels_ind = [yticklabels [i ] for i in inds ]
202+ ax .set_yticks (np .arange (len (labels_ind )) + 0.5 )
196203 ax .set_yticklabels (labels_ind )
197204
198205 return ax
0 commit comments