title: plot dataset and labels over multiple rows (jupyter notebook)
body: <p>I have the following code below which simply plots datasets (consisting of dogs and cats images) and their labels. I'm using jupyter notebook:</p>
  
  <pre class="lang-py prettyprint-override"><code>train_path = 'dataset/train'
  valid_path = 'dataset/valid'
  test_path = 'dataset/test'
  
  train_batches = ImageDataGenerator().flow_from_directory(train_path, target_size=(224,224), classes=['dog', 'cat'], batch_size=10)
  valid_batches = ImageDataGenerator().flow_from_directory(valid_path, target_size=(224,224), classes=['dog', 'cat'], batch_size=4)
  test_batches = ImageDataGenerator().flow_from_directory(test_path, target_size=(224,224), classes=['dog', 'cat'], batch_size=10)
  
  # plot function, used to plot images with labels within jupyter notebook
  def plots(ims, figsize=(12,6), rows=1, interp=False, titles=None):
      if type(ims[0]) is np.ndarray:
          ims= np.array(ims).astype(np.uint8)
          if (ims.shape[-1] != 3):
              ims = ims.transpose((0,2,3,1))
      f = plt.figure(figsize=figsize)
      cols = len(ims)//rows if len(ims) % 2 == 0 else len(ims)//rows + 1
      for i in range(len(ims)):
          sp = f.add_subplot(rows, cols, i+1)
          sp.axis('off')
          if titles is not None:
              sp.set_title(titles[i], fontsize=16)
          plt.imshow(ims[i], interpolation=None if interp else 'none')
  
  imgs, labels = next(train_batches)
  
  # we plot these samples of images and their labels 1 batch at a time.
  plots(imgs, titles=labels)
  </code></pre>
  
  <p>If I use only 10 samples per batch as per the code above, this fits adequately along the notebook page width: </p>
  
  <p><a href="https://imgur.com/abLaPel" rel="nofollow noreferrer"><img src="https://i.imgur.com/abLaPel.jpg" title="10 imags plot" /></a></p>
  
  <p>But if I want to change the batch size to more than that, say 100 samples (or any size) in a batch (i.e. in the code <code>train_batches = ImageDataGenerator()</code> change <code>batch_size=100</code>), and plot this, it will just try to squeeze it all inline on 1 row, as per the screenshot below:
  <a href="https://imgur.com/7Hyl95t" rel="nofollow noreferrer"><img src="https://i.imgur.com/7Hyl95t.jpg" title="100 images plot" /></a></p>
  
  <p>How do I change this in the code so it plots all 100 data samples to fit adequately across multiple rows, rather than squeeze them all (to a tiny size) in a single row. </p>
  
  <p>Many thanks in advance.</p>