Changeset 2362 in lmdz_wrf


Ignore:
Timestamp:
Feb 22, 2019, 4:54:48 PM (6 years ago)
Author:
lfita
Message:

Adding:

  • `NcolNrow_figure': Function to provide the number of rows and columns for a panel of figures always more rows than columns
File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/tools/drawing_tools.py

    r2323 r2362  
    159159# movie_2D_shadow: Plot of a 2D field with shadow
    160160# multi_plot_2D_shadow: plot of multiple 2D shadowing variables sharing colorbar
     161# NcolNrow_figure: Function to provide the number of rows and columns for a panel of
     162#   figures always more rows than columns
    161163# pixelgrid: Function to provide the kind of grid distribution for a plot
    162164# plot_points:
     
    31053107    return figsizev, txtlineh
    31063108
     3109def NcolNrow_figure(Npanels):
     3110    """ Function to provide the number of rows and columns for a panel of figures
     3111        always more rows than columns
     3112      Npanels: number of panels to be included in the figure
     3113    >>> NcolNrow_figure(10)
     3114    3, 4, [[3, 1], [3, 2]]
     3115    """
     3116    fname = 'NcolNrow_figure'
     3117
     3118    Ncol = int(np.sqrt(Npanels))
     3119    Nrow = Npanels / Ncol + 1
     3120
     3121    if Ncol > Nrow:
     3122        Ncol0 = Ncol + 0
     3123        Ncol = Nrow + 0
     3124        Nrow = Ncol0
     3125
     3126    # panel array without draw
     3127    NOpanels = []
     3128    panels = np.arange(Ncol*Nrow).reshape(Nrow,Ncol)
     3129    ipanel = 0
     3130    for ic in range(Ncol):
     3131        for ir in range(Nrow):
     3132            if panels[ir,ic] > Npanels-1: NOpanels.append([ir,ic])
     3133            ipanel = ipanel + 1
     3134
     3135    return Ncol, Nrow, NOpanels
     3136print NcolNrow_figure(10)
     3137quit()
     3138
     3139
    31073140####### ###### ##### #### ### ## # END of GENERIC functions
    31083141
Note: See TracChangeset for help on using the changeset viewer.