def get_best_layout(n_plots):
 assert (n_plots > 0)
 n_rows = 1
 n_cols = np.ceil(((n_plots * 1.0) / n_rows))
 n_cols = int(n_cols)
 half_perimeter = (n_cols + 1)
 max_row = np.sqrt(n_plots)
 max_row = np.round(max_row)
 max_row = int(max_row)
 for l in xrange(1, (max_row + 1)):
  width = np.ceil(((n_plots * 1.0) / l))
  width = int(width)
  if (half_perimeter >= (width + l)):
   n_rows = l
   n_cols = np.ceil(((n_plots * 1.0) / n_rows))
   n_cols = int(n_cols)
   half_perimeter = (n_rows + n_cols)
 return (n_rows, n_cols)

def get_best_layout ( n_plots ) : assert ( n_plots > 0 ) n_rows = 1 n_cols = np . ceil ( ( ( n_plots * 1.0 ) / n_rows ) ) n_cols = int ( n_cols ) half_perimeter = ( n_cols + 1 ) max_row = np . sqrt ( n_plots ) max_row = np . round ( max_row ) max_row = int ( max_row ) for l in xrange ( 1 , ( max_row + 1 ) ) : width = np . ceil ( ( ( n_plots * 1.0 ) / l ) ) width = int ( width ) if ( half_perimeter >= ( width + l ) ) : n_rows = l n_cols = np . ceil ( ( ( n_plots * 1.0 ) / n_rows ) ) n_cols = int ( n_cols ) half_perimeter = ( n_rows + n_cols ) return ( n_rows , n_cols )
find the best basic layout for a given number of plots .