original_docstring: Create stacked adjacency to illustrate similarity.
  
      Args:
          matrix1:  Adjacency instance 1
          matrix2:  Adjacency instance 2
          normalize: (boolean) Normalize matrices.
  
      Returns:
          matplotlib figure
      
docstring: Create stacked adjacency to illustrate similarity.
docstring_tokens: Create stacked adjacency to illustrate similarity .
code: def plot_stacked_adjacency(adjacency1, adjacency2, normalize=True, **kwargs):
      """Create stacked adjacency to illustrate similarity.
  
      Args:
          matrix1:  Adjacency instance 1
          matrix2:  Adjacency instance 2
          normalize: (boolean) Normalize matrices.
  
      Returns:
          matplotlib figure
      """
      from nltools.data import Adjacency
  
      if not isinstance(adjacency1, Adjacency) or not isinstance(adjacency2, Adjacency):
          raise ValueError("This function requires Adjacency() instances as input.")
  
      upper = np.triu(adjacency2.squareform(), k=1)
      lower = np.tril(adjacency1.squareform(), k=-1)
      if normalize:
          upper = np.triu((adjacency1 - adjacency1.mean()).squareform(), k=1)
          lower = np.tril((adjacency2 - adjacency2.mean()).squareform(), k=-1)
          upper = upper / np.max(upper)
          lower = lower / np.max(lower)
      dist = upper + lower
      return sns.heatmap(
          dist, xticklabels=False, yticklabels=False, square=True, **kwargs
      )
code_tokens: def plot_stacked_adjacency ( adjacency1 , adjacency2 , normalize = True , ** kwargs ) : from nltools . data import Adjacency if not isinstance ( adjacency1 , Adjacency ) or not isinstance ( adjacency2 , Adjacency ) : raise ValueError ( "This function requires Adjacency() instances as input." ) upper = np . triu ( adjacency2 . squareform ( ) , k = 1 ) lower = np . tril ( adjacency1 . squareform ( ) , k = - 1 ) if normalize : upper = np . triu ( ( adjacency1 - adjacency1 . mean ( ) ) . squareform ( ) , k = 1 ) lower = np . tril ( ( adjacency2 - adjacency2 . mean ( ) ) . squareform ( ) , k = - 1 ) upper = upper / np . max ( upper ) lower = lower / np . max ( lower ) dist = upper + lower return sns . heatmap ( dist , xticklabels = False , yticklabels = False , square = True , ** kwargs )
short_docstring: Create stacked adjacency to illustrate similarity.
short_docstring_tokens: Create stacked adjacency to illustrate similarity .
comment: """Create stacked adjacency to illustrate similarity.
  
      Args:
          matrix1:  Adjacency instance 1
          matrix2:  Adjacency instance 2
          normalize: (boolean) Normalize matrices.
  
      Returns:
          matplotlib figure
      """