@@ -1648,7 +1648,7 @@ def _normalize_grid_string(layout):
16481648 layout = inspect .cleandoc (layout )
16491649 return [list (ln ) for ln in layout .strip ('\n ' ).split ('\n ' )]
16501650
1651- def subplot_mosaic (self , layout , * , sharex = False , sharey = False ,
1651+ def subplot_mosaic (self , mosaic , * , sharex = False , sharey = False ,
16521652 subplot_kw = None , gridspec_kw = None , empty_sentinel = '.' ):
16531653 """
16541654 Build a layout of Axes based on ASCII art or nested lists.
@@ -1662,7 +1662,7 @@ def subplot_mosaic(self, layout, *, sharex=False, sharey=False,
16621662
16631663 Parameters
16641664 ----------
1665- layout : list of list of {hashable or nested} or str
1665+ mosaic : list of list of {hashable or nested} or str
16661666
16671667 A visual layout of how you want your Axes to be arranged
16681668 labeled as strings. For example ::
@@ -1727,8 +1727,8 @@ def subplot_mosaic(self, layout, *, sharex=False, sharey=False,
17271727 subplot_kw = subplot_kw or {}
17281728 gridspec_kw = gridspec_kw or {}
17291729 # special-case string input
1730- if isinstance (layout , str ):
1731- layout = self ._normalize_grid_string (layout )
1730+ if isinstance (mosaic , str ):
1731+ mosaic = self ._normalize_grid_string (mosaic )
17321732 # Only accept strict bools to allow a possible future API expansion.
17331733 _api .check_isinstance (bool , sharex = sharex , sharey = sharey )
17341734
@@ -1748,10 +1748,10 @@ def _make_array(inp):
17481748 """
17491749 r0 , * rest = inp
17501750 if isinstance (r0 , str ):
1751- raise ValueError ('List layout specification must be 2D' )
1751+ raise ValueError ('List mosaic specification must be 2D' )
17521752 for j , r in enumerate (rest , start = 1 ):
17531753 if isinstance (r , str ):
1754- raise ValueError ('List layout specification must be 2D' )
1754+ raise ValueError ('List mosaic specification must be 2D' )
17551755 if len (r0 ) != len (r ):
17561756 raise ValueError (
17571757 "All of the rows must be the same length, however "
@@ -1764,24 +1764,24 @@ def _make_array(inp):
17641764 out [j , k ] = v
17651765 return out
17661766
1767- def _identify_keys_and_nested (layout ):
1767+ def _identify_keys_and_nested (mosaic ):
17681768 """
1769- Given a 2D object array, identify unique IDs and nested layouts
1769+ Given a 2D object array, identify unique IDs and nested mosaics
17701770
17711771 Parameters
17721772 ----------
1773- layout : 2D numpy object array
1773+ mosaic : 2D numpy object array
17741774
17751775 Returns
17761776 -------
17771777 unique_ids : tuple
1778- The unique non-sub layout entries in this layout
1778+ The unique non-sub mosaic entries in this mosaic
17791779 nested : dict[tuple[int, int]], 2D object array
17801780 """
17811781 # make sure we preserve the user supplied order
17821782 unique_ids = cbook ._OrderedSet ()
17831783 nested = {}
1784- for j , row in enumerate (layout ):
1784+ for j , row in enumerate (mosaic ):
17851785 for k , v in enumerate (row ):
17861786 if v == empty_sentinel :
17871787 continue
@@ -1792,102 +1792,102 @@ def _identify_keys_and_nested(layout):
17921792
17931793 return tuple (unique_ids ), nested
17941794
1795- def _do_layout (gs , layout , unique_ids , nested ):
1795+ def _do_layout (gs , mosaic , unique_ids , nested ):
17961796 """
1797- Recursively do the layout .
1797+ Recursively do the mosaic .
17981798
17991799 Parameters
18001800 ----------
18011801 gs : GridSpec
1802- layout : 2D object array
1802+ mosaic : 2D object array
18031803 The input converted to a 2D numpy array for this level.
18041804 unique_ids : tuple
18051805 The identified scalar labels at this level of nesting.
18061806 nested : dict[tuple[int, int]], 2D object array
1807- The identified nested layouts , if any.
1807+ The identified nested mosaics , if any.
18081808
18091809 Returns
18101810 -------
18111811 dict[label, Axes]
18121812 A flat dict of all of the Axes created.
18131813 """
1814- rows , cols = layout .shape
1814+ rows , cols = mosaic .shape
18151815 output = dict ()
18161816
18171817 # we need to merge together the Axes at this level and the axes
1818- # in the (recursively) nested sub-layouts so that we can add
1818+ # in the (recursively) nested sub-mosaics so that we can add
18191819 # them to the figure in the "natural" order if you were to
18201820 # ravel in c-order all of the Axes that will be created
18211821 #
18221822 # This will stash the upper left index of each object (axes or
1823- # nested layout ) at this level
1823+ # nested mosaic ) at this level
18241824 this_level = dict ()
18251825
18261826 # go through the unique keys,
18271827 for name in unique_ids :
18281828 # sort out where each axes starts/ends
1829- indx = np .argwhere (layout == name )
1829+ indx = np .argwhere (mosaic == name )
18301830 start_row , start_col = np .min (indx , axis = 0 )
18311831 end_row , end_col = np .max (indx , axis = 0 ) + 1
18321832 # and construct the slice object
18331833 slc = (slice (start_row , end_row ), slice (start_col , end_col ))
18341834 # some light error checking
1835- if (layout [slc ] != name ).any ():
1835+ if (mosaic [slc ] != name ).any ():
18361836 raise ValueError (
1837- f"While trying to layout\n { layout !r} \n "
1837+ f"While trying to layout\n { mosaic !r} \n "
18381838 f"we found that the label { name !r} specifies a "
18391839 "non-rectangular or non-contiguous area." )
18401840 # and stash this slice for later
18411841 this_level [(start_row , start_col )] = (name , slc , 'axes' )
18421842
1843- # do the same thing for the nested layouts (simpler because these
1843+ # do the same thing for the nested mosaics (simpler because these
18441844 # can not be spans yet!)
1845- for (j , k ), nested_layout in nested .items ():
1846- this_level [(j , k )] = (None , nested_layout , 'nested' )
1845+ for (j , k ), nested_mosaic in nested .items ():
1846+ this_level [(j , k )] = (None , nested_mosaic , 'nested' )
18471847
18481848 # now go through the things in this level and add them
18491849 # in order left-to-right top-to-bottom
18501850 for key in sorted (this_level ):
18511851 name , arg , method = this_level [key ]
18521852 # we are doing some hokey function dispatch here based
18531853 # on the 'method' string stashed above to sort out if this
1854- # element is an axes or a nested layout .
1854+ # element is an axes or a nested mosaic .
18551855 if method == 'axes' :
18561856 slc = arg
18571857 # add a single axes
18581858 if name in output :
18591859 raise ValueError (f"There are duplicate keys { name } "
1860- f"in the layout\n { layout !r} " )
1860+ f"in the layout\n { mosaic !r} " )
18611861 ax = self .add_subplot (
18621862 gs [slc ], ** {'label' : str (name ), ** subplot_kw }
18631863 )
18641864 output [name ] = ax
18651865 elif method == 'nested' :
1866- nested_layout = arg
1866+ nested_mosaic = arg
18671867 j , k = key
1868- # recursively add the nested layout
1869- rows , cols = nested_layout .shape
1868+ # recursively add the nested mosaic
1869+ rows , cols = nested_mosaic .shape
18701870 nested_output = _do_layout (
18711871 gs [j , k ].subgridspec (rows , cols , ** gridspec_kw ),
1872- nested_layout ,
1873- * _identify_keys_and_nested (nested_layout )
1872+ nested_mosaic ,
1873+ * _identify_keys_and_nested (nested_mosaic )
18741874 )
18751875 overlap = set (output ) & set (nested_output )
18761876 if overlap :
18771877 raise ValueError (
18781878 f"There are duplicate keys { overlap } "
1879- f"between the outer layout\n { layout !r} \n "
1880- f"and the nested layout\n { nested_layout } "
1879+ f"between the outer layout\n { mosaic !r} \n "
1880+ f"and the nested layout\n { nested_mosaic } "
18811881 )
18821882 output .update (nested_output )
18831883 else :
18841884 raise RuntimeError ("This should never happen" )
18851885 return output
18861886
1887- layout = _make_array (layout )
1888- rows , cols = layout .shape
1887+ mosaic = _make_array (mosaic )
1888+ rows , cols = mosaic .shape
18891889 gs = self .add_gridspec (rows , cols , ** gridspec_kw )
1890- ret = _do_layout (gs , layout , * _identify_keys_and_nested (layout ))
1890+ ret = _do_layout (gs , mosaic , * _identify_keys_and_nested (mosaic ))
18911891 ax0 = next (iter (ret .values ()))
18921892 for ax in ret .values ():
18931893 if sharex :
0 commit comments