• Basic use

      import matplotlib.pyplot as plt
      import matplotlib
    
  • Hide toolbar

      matplotlib.rcParams['toolbar'] = 'None'
    
  • Set window size

      plt.figure(figsize=(10, 2)) # (x, y) inch
    
  • Adjust layout automatically

      fig.tight_layout()
    
  • Adjust margin of figure

      plt.subplots_adjust(left=0.1, right=0.9, top=0.9, bottom=0.1)
      # (start:left - end:right), (start:bottom - end:top)
      # must right > left, top > bottom
    
  • Adjust padding of figure

      plt.margins(0.05, 0.1) # margins of x, y direction
    
  • Live plotting

      plt.ion()
      fig = plt.figure() # show figure first
      
      # plot data
    
  • Clear figure / plot

      plt.clf()
      plt.cla()
    
  • Close figure

      plt.close()