This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from PIL import Image | |
| import io, imageio | |
| from matplotlib.figure import Figure | |
| class Camera: | |
| """ | |
| Adaptation from https://github.com/jwkvam/celluloid/blob/master/celluloid.py | |
| This makes complete snapshots of the figure, not only the new artists | |
| """ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from typing import Dict, List | |
| from collections import defaultdict | |
| from matplotlib.figure import Figure | |
| from matplotlib.artist import Artist | |
| from matplotlib.animation import ArtistAnimation | |
| class Camera: | |
| """Make animations easier. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def gs_from_array(layout, figsize = None, **kwargs): | |
| """ | |
| makes a matplotlib.gridspec from a layout given by an array. | |
| ie: | |
| layout = np.array([[0, 0, 1, 1], | |
| [0, 0, 1, 1], | |
| [0, 0, 2, 2]]) | |
| will create a 3x4 Gridspec with: | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import numpy as np | |
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| def htext(s, x, y, | |
| highlight_colors = ['C0'], | |
| color = 'w', | |
| ax = None, | |
| delim = ['<', '>'], | |
| hpadding = 0, | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def colored_text_ax(s, x, y, | |
| color = 'w', | |
| ax = None, | |
| xlim = None, | |
| highlight_colors = ['C0'], | |
| hpadding = 0, | |
| **kwargs): | |
| ''' | |
| takes a string with substrings in {} to be highlighted according to highlight colors: | |
| 'The weather is {sunny} today. Yesterday it {rained}.', color = 'w', highlight_colors = ['yellow', 'grey'] |