def zr_density_pdf(ax,Z,R,title=None,grid=(80,60),minct=0.01,
                   xlabFontSize=16,xpad=7,ylabFontSize=16,ypad=7,
                   xlims=(-3,3),ylims=(-20.,60.)):
    """Create a density scatterplot using the hex bin method (color marker based on density)
 INPUT::
  ax              = Axis to plot against (produced externally)
  Z               = Reflectivity factor [mm^6/m^3]
  R               = Rainfall rate [mm/h]
     OPTIONAL
  title           = Plot title
  grid            = The bin size in (x,y) to be used
  minct           = Minimum count to be displayed
 OUTPUT::
  p               = Plot
 USAGE::
  p = zr_density_pdf(ax,Z,R,**args)
    """
# HISTORY::
#  10 Mar 2014 - Nick Guy NOAA/NSSL/WRDD, NRC
#--------------------------------------------------------
    # First calculate the 2D PDF
    pdf2_Z_R, xedges, yedges = gl.hist2d_masked(10.*np.log10(Z),np.log10(R),bins=grid,
                                                rng=(ylims,xlims),norm=True)
    
    # Replace any zero values with missing data for nice plots
    pdf2_Z_R = np.ma.masked_equal(pdf2_Z_R,0)
    
    # Flip and rotate the 2D Histogram
    pdf2_Z_R = np.rot90(pdf2_Z_R)
    pdf2_Z_R = np.flipud(pdf2_Z_R)
    
    # Create 2D arrays from xedges, yedges
    X, Y = np.meshgrid(xedges, yedges)
    
    # Plot the data using colormesh
    plt.pcolormesh(X,Y,pdf2_Z_R)#,cmap=

    plt.ylim(xlims) # Set X-axis limits
    plt.xlim(ylims) # Set Y-axis limits
    
    # First remove italics from mathtext then label axes
    plt.rc('mathtext',fontset='stixsans',default='regular') # Removes italics mathtext
    plt.xlabel(r'Reflectivity (dBZ)',labelpad=xpad,fontsize=ylabFontSize)
    plt.ylabel(r'log$_{10}$Rainfall Rate (mm h$^{-1}$)',labelpad=ypad,fontsize=xlabFontSize)
    
    ax.set_title(title) # Set the plot title
    
    # Add colorbar
    cb = plt.colorbar(shrink=0.85)
    cb.set_label('Normalized Counts')
    
    del pdf2_Z_R,xedges,yedges,X,Y
    
    return
def Nw_D0_density_pdf(ax,Nw,D0,title=None,grid=(36,61),minct=0.01,
                   xlabFontSize=16,xpad=7,ylabFontSize=16,ypad=7,
                   xlims=(0.1,3.5),ylims=(1.0,7.0)):
    """Create a density scatterplot using 2D histogram
 INPUT::
  ax              = Axis to plot against (produced externally)
  Nw              = Normalized intercept parameter [mm^-1 m^-3]
  D0              = Median volume diameter [mm]
     OPTIONAL
  title           = Plot title
  grid            = The bin size in (x,y) to be used
  minct           = Minimum count to be displayed
 OUTPUT::
  p               = Plot
 USAGE::
  p = Nw_D0_density_pdf(ax,Nw,D0,**args)
    """
# HISTORY::
#  10 Mar 2014 - Nick Guy NOAA/NSSL/WRDD, NRC
#--------------------------------------------------------
    # First calculate the 2D PDF
    pdf2_Nw_D0, xedges, yedges = gl.hist2d_masked(D0,np.log10(Nw),bins=grid,
                                                rng=(ylims,xlims),norm=True)
    
    # Replace any zero values with missing data for nice plots
    pdf2_Nw_D0 = np.ma.masked_equal(pdf2_Nw_D0,0)
    
    # Flip and rotate the 2D Histogram
    pdf2_Nw_D0 = np.rot90(pdf2_Nw_D0)
    pdf2_Nw_D0 = np.flipud(pdf2_Nw_D0)
    
    # Create 2D arrays from xedges, yedges
    X, Y = np.meshgrid(xedges, yedges)
    
    # Plot the data using colormesh
    plt.pcolormesh(X,Y,pdf2_Nw_D0)#,cmap=

    plt.ylim(xlims) # Set X-axis limits
    plt.xlim(ylims) # Set Y-axis limits
    
    # First remove italics from mathtext then label axes
    plt.rc('mathtext',fontset='stixsans',default='regular') # Removes italics mathtext
    plt.xlabel(r'D$_0$ (mm)',labelpad=xpad,fontsize=ylabFontSize)
    plt.ylabel(r'log$_{10}$[N$_w$] (mm$^{-1}$ m$^{-3}$)',labelpad=ypad,fontsize=xlabFontSize)
    
    ax.set_title(title) # Set the plot title
    
    # Add colorbar
    cb = plt.colorbar(shrink=0.85)
    cb.set_label('Normalized Counts')
    
    del pdf2_Nw_D0,xedges,yedges,X,Y
    
    return