code: def n2mfrow(nr_plots):
      
      if nr_plots <= 3:
          nrow, ncol = nr_plots, 1
      elif nr_plots <= 6:
          nrow, ncol = (nr_plots + 1) // 2, 2
      elif nr_plots <= 12:
          nrow, ncol = (nr_plots + 2) // 3, 3
      else:
          nrow = int(np.ceil(np.sqrt(nr_plots)))
          ncol = int(np.ceil(nr_plots/nrow))
      return (nrow, ncol)
docs: Compute the rows and columns given the number
      of plots.
  
      This is a port of grDevices::n2mfrow from R