11import matplotlib as mpl
2- import matplotlib .pyplot as plt
32import numpy as np
43from matplotlib .colors import from_levels_and_colors
54
@@ -67,7 +66,7 @@ def _color_palette(cmap, n_colors):
6766 except ValueError :
6867 # ValueError happens when mpl doesn't like a colormap, try seaborn
6968 try :
70- from seaborn . apionly import color_palette
69+ from seaborn import color_palette
7170
7271 pal = color_palette (cmap , n_colors = n_colors )
7372 except (ValueError , ImportError ):
@@ -81,70 +80,6 @@ def _color_palette(cmap, n_colors):
8180 return pal
8281
8382
84- def set_map_layout (axes , width = 17.0 , nrow = None , ncol = None ):
85- """
86- set figure height, given width
87-
88- Needs to be called after all plotting is done.
89-
90- Parameters
91- ----------
92- axes : ndarray of (Geo)Axes
93- Array with all axes of the figure.
94- width : float, default: 17
95- Width of the full figure in cm.
96- nrow : integer, default: None
97- manually set the number of rows of subplots. Good when using gridspec.
98- However, subplots must span the same number of gridspec rows & columns.
99- Either none or both of 'nrow' and 'ncol' must be set.
100- ncol : integer, default: None
101- As nrow but for the number of rows.
102-
103- Notes
104- -----
105- Only works if all the axes have the same aspect ratio.
106- """
107-
108- if (nrow is None and ncol is not None ) or (nrow is not None and ncol is None ):
109- raise ValueError ("Must set none or both of 'nrow' and 'ncol'" )
110-
111- if isinstance (axes , plt .Axes ):
112- ax = axes
113- else :
114- # assumes the first of the axes is representative for all
115- ax = axes .flat [0 ]
116-
117- # read figure data
118- f = ax .get_figure ()
119-
120- bottom = f .subplotpars .bottom
121- top = f .subplotpars .top
122- left = f .subplotpars .left
123- right = f .subplotpars .right
124- hspace = f .subplotpars .hspace
125- wspace = f .subplotpars .wspace
126-
127- # data ratio is the aspect
128- aspect = ax .get_data_ratio ()
129-
130- if nrow is None and ncol is None :
131- # get geometry tells how many subplots there are
132- nrow , ncol , __ , __ = ax .get_subplotspec ().get_geometry ()
133-
134- # width of one plot, taking into account
135- # left * wf, (1-right) * wf, ncol * wp, (1-ncol) * wp * wspace
136- wp = (width - width * (left + (1 - right ))) / (ncol + (ncol - 1 ) * wspace )
137-
138- # height of one plot
139- hp = wp * aspect
140-
141- # height of figure
142- height = (hp * (nrow + ((nrow - 1 ) * hspace ))) / (1.0 - (bottom + (1 - top )))
143-
144- f .set_figwidth (width / 2.54 )
145- f .set_figheight (height / 2.54 )
146-
147-
14883def _get_label_attr (labelpad , size , weight ):
14984
15085 if labelpad is None :
0 commit comments