import matplotlib.pyplot as plt


def imshow(*args, **kwargs):
    kwargs.setdefault('interpolation', 'nearest')
    kwargs.setdefault('cmap', 'gray')
    plt.imshow(*args, **kwargs)

imread = plt.imread
show = plt.show


def _app_show():
    show()

import matplotlib.pyplot as plt


def imshow(*args, **kwargs):
    if plt.gca().has_data():
        plt.figure()
    kwargs.setdefault('interpolation', 'nearest')
    kwargs.setdefault('cmap', 'gray')
    plt.imshow(*args, **kwargs)

imread = plt.imread
show = plt.show


def _app_show():
    show()

Create a new figure for imshow if there is already data
Create a new figure for imshow if there is already data

  import matplotlib.pyplot as plt
  
  
  def imshow(*args, **kwargs):
+     if plt.gca().has_data():
+         plt.figure()
      kwargs.setdefault('interpolation', 'nearest')
      kwargs.setdefault('cmap', 'gray')
      plt.imshow(*args, **kwargs)
  
  imread = plt.imread
  show = plt.show
  
  
  def _app_show():
      show()
  
Create a new figure for imshow if there is already data
## Code Before:
import matplotlib.pyplot as plt


def imshow(*args, **kwargs):
    kwargs.setdefault('interpolation', 'nearest')
    kwargs.setdefault('cmap', 'gray')
    plt.imshow(*args, **kwargs)

imread = plt.imread
show = plt.show


def _app_show():
    show()

## Instruction:
Create a new figure for imshow if there is already data
## Code After:
import matplotlib.pyplot as plt


def imshow(*args, **kwargs):
    if plt.gca().has_data():
        plt.figure()
    kwargs.setdefault('interpolation', 'nearest')
    kwargs.setdefault('cmap', 'gray')
    plt.imshow(*args, **kwargs)

imread = plt.imread
show = plt.show


def _app_show():
    show()
