old_contents: import matplotlib.pyplot as plt
  
  
  class ImageWindow:
      def __init__(self):
          self.imsh = None
          plt.ion()
          plt.show()
  
      def display(self, image):
          if self.imsh is None or not plt.fignum_exists(self.imsh.figure.number):
              self.imsh = plt.imshow(image, interpolation='nearest')
              self.imsh.axes.axis('off')
              self.imsh.figure.canvas.draw()
          else:
              self.imsh.set_data(image)
          plt.pause(1e-4)
  
new_contents: import matplotlib.pyplot as plt
  
  
  class ImageWindow:
      def __init__(self):
          self.imsh = None
          plt.ion()
          plt.show()
  
      def display(self, image):
          if self.imsh is None or not plt.fignum_exists(self.imsh.figure.number):
              self.imsh = plt.imshow(image, interpolation='nearest')
              self.imsh.axes.axis('off')
              self.imsh.axes.set_position((0, 0, 1, 1))
              self.imsh.figure.canvas.draw()
          else:
              self.imsh.set_data(image)
          plt.pause(1e-4)
  
subject: Set image to fill the entire matplotlib window