@@ -53,7 +53,7 @@ class FacetGrid(object):
53
53
The basic workflow is to initialize the :class:`FacetGrid` object with
54
54
the DataArray and the variable names that are used to structure the grid. Then
55
55
one or more plotting functions can be applied to each subset by calling
56
- :meth:`FacetGrid.map_dataarray` or :meth:`FacetGrid.map`.
56
+ :meth:`FacetGrid.map_dataarray` or :meth:`FacetGrid.map`.
57
57
58
58
Attributes
59
59
----------
@@ -78,7 +78,7 @@ def __init__(self, darray, col=None, row=None, col_wrap=None,
78
78
xray DataArray to be plotted
79
79
row, col : strings
80
80
Dimesion names that define subsets of the data, which will be drawn on
81
- separate facets in the grid.
81
+ separate facets in the grid.
82
82
col_wrap : int, optional
83
83
"Wrap" the column variable at this width, so that the column facets
84
84
aspect : scalar, optional
@@ -257,19 +257,23 @@ def map_dataarray(self, plotfunc, x, y, max_xticks=4, max_yticks=4,
257
257
for ax in self .axes [- 1 , :]:
258
258
ax .set_xlabel (self .x )
259
259
260
- # colorbar
261
- if kwargs .get ('add_colorbar' , True ):
260
+ self .fig .tight_layout ()
262
261
263
- self .fig .subplots_adjust (right = 0.8 )
262
+ if self ._single_group :
263
+ for d , ax in zip (self .name_dicts .flat , self .axes .flat ):
264
+ if d is None :
265
+ ax .set_visible (False )
264
266
265
- cbar_ax = self .fig .add_axes ([0.85 , 0.15 , 0.05 , 0.7 ])
266
- cbar = self .fig .colorbar (mappable , cax = cbar_ax ,
267
- extend = cmap_params ['extend' ])
267
+ # colorbar
268
+ if kwargs .get ('add_colorbar' , True ):
269
+ cbar = self .fig .colorbar (mappable ,
270
+ ax = list (self .axes .flat ),
271
+ extend = cmap_params ['extend' ])
268
272
269
273
if self .darray .name :
270
274
cbar .set_label (self .darray .name , rotation = 270 ,
271
275
verticalalignment = 'bottom' )
272
-
276
+
273
277
# This happens here rather than __init__ since FacetGrid.map should
274
278
# use default ticks
275
279
self .set_ticks (max_xticks , max_yticks , fontsize )
@@ -307,13 +311,11 @@ def set_titles(self, template="{coord} = {value}", maxchar=30,
307
311
308
312
if self ._single_group :
309
313
for d , ax in zip (self .name_dicts .flat , self .axes .flat ):
310
- # Only plot the ones with data
314
+ # Only label the ones with data
311
315
if d is not None :
312
316
coord , value = list (d .items ()).pop ()
313
317
title = nicetitle (coord , value , maxchar = maxchar )
314
318
ax .set_title (title , ** kwargs )
315
- else :
316
- ax .set_visible (False )
317
319
else :
318
320
# The row titles on the right edge of the grid
319
321
if self ._margin_titles :
@@ -333,7 +335,7 @@ def set_ticks(self, max_xticks=_NTICKS, max_yticks=_NTICKS, fontsize=_FONTSIZE):
333
335
'''
334
336
Sets tick behavior.
335
337
336
- Refer to documentation in :meth:`FacetGrid.map_dataarray`
338
+ Refer to documentation in :meth:`FacetGrid.map_dataarray`
337
339
'''
338
340
from matplotlib .ticker import MaxNLocator
339
341
0 commit comments