def corr_multi(corr2d, **pltkwargs):
    """ """
    
    sync = corr2d.sync #Used to look up some span attributes for now
    
    # Boilerplate multiplot

    _title_default = '%s (%s)  scale: %s' \
        % (corr2d.spec.name, sync._var_span, corr2d._scale_string)
    
    title = pltkwargs.pop('title', _title_default)
    grid = pltkwargs.pop('grid', True)
    tight_layout = pltkwargs.pop('tight_layout', False)
    figsize = pltkwargs.pop('figsize', (8,8))

    f, (ax1, ax2, ax3, ax4) = pvutil.splot(2,2, fig=True, figsize=figsize)
    f.suptitle(title) #, fontsize=20)
    if tight_layout:
        f.tight_layout()
        
    if 'cbar' in pltkwargs:
        raise NotImplementedError('Colorbar not supported.')
        
 
    ax1 = corr2d.dyn_spec.plot(ax=ax1,
                           title='Dynamic Spectra',
                           color='k')    


    pltkwargs['sideplots'] = None #Necessary
    pltkwargs['kind'] = 'corr2d'


    ax2 = corr2d.async_codist.plot(ax=ax2,
                                   title='Async. Codistribution ($\Delta$)', 
                                   **pltkwargs)

    ax3 = sync.plot(ax=ax3, 
                           title='Sync. Correlation ($\Phi$)',
                            **pltkwargs)

    ax4 = corr2d.async.plot(ax=ax4,
                            title='Async. Correlation ($\Psi$)',
                            **pltkwargs)


    # Hide axis labels
    for ax in (ax1, ax2, ax3, ax4):
        if grid:
            pvutil.hide_axis(ax, axis='both', axislabel=True, ticklabels=True)
        else:
            pvutil.hide_axis(ax, axis='both', hide_everything = True)    

    # Soft diagonal line
    for ax in (ax2, ax3, ax4):
        pvutil.diag_line(ax)     

    return (ax1, ax2, ax3, ax4)
    
Beispiel #2
0
def corr_multi(corr2d, **pltkwargs):
    """ """

    sync = corr2d.sync  #Used to look up some span attributes for now

    # Boilerplate multiplot

    _title_default = '%s (%s)  scale: %s' \
        % (corr2d.spec.name, sync._var_span, corr2d._scale_string)

    title = pltkwargs.pop('title', _title_default)
    grid = pltkwargs.pop('grid', True)
    tight_layout = pltkwargs.pop('tight_layout', False)
    figsize = pltkwargs.pop('figsize', (8, 8))

    f, (ax1, ax2, ax3, ax4) = pvutil.splot(2, 2, fig=True, figsize=figsize)
    f.suptitle(title)  #, fontsize=20)
    if tight_layout:
        f.tight_layout()

    if 'cbar' in pltkwargs:
        raise NotImplementedError('Colorbar not supported.')

    ax1 = corr2d.dyn_spec.plot(ax=ax1, title='Dynamic Spectra', color='k')

    pltkwargs['sideplots'] = None  #Necessary
    pltkwargs['kind'] = 'corr2d'

    ax2 = corr2d.async_codist.plot(ax=ax2,
                                   title='Async. Codistribution ($\Delta$)',
                                   **pltkwargs)

    ax3 = sync.plot(ax=ax3, title='Sync. Correlation ($\Phi$)', **pltkwargs)

    ax4 = corr2d. async .plot(ax=ax4,
                              title='Async. Correlation ($\Psi$)',
                              **pltkwargs)

    # Hide axis labels
    for ax in (ax1, ax2, ax3, ax4):
        if grid:
            pvutil.hide_axis(ax, axis='both', axislabel=True, ticklabels=True)
        else:
            pvutil.hide_axis(ax, axis='both', hide_everything=True)

    # Soft diagonal line
    for ax in (ax2, ax3, ax4):
        pvutil.diag_line(ax)

    return (ax1, ax2, ax3, ax4)
def _corr2d4fig(spec, a1_label=r'$\bar{A}(\nu_1)$', 
               a2_label=r'$\bar{A}(\nu_2)$', **contourkwds): 
    """ Abstract layout for 2d correlation analysis plot.  
    
    **contourkwds
        Passed directly to _gencontour; includes keywords like xlabel, ylabel
        and so forth.
    """

    # Maybe this should take X, Y, Z not ts

    #fig, ax #how to handle these in general 2d
    # Maybe it's helpful to have args for top plots (ie ax1,2,3)
    
    title = contourkwds.pop('title', '')
    cbar = contourkwds.pop('cbar', False)
    grid = contourkwds.setdefault('grid', True) #Adds grid to plot and side plots
    
    # REFACTOR THIS
    cbar_nticks = 5
  
    
    # This will create a fig
    ax1 = plt.subplot2grid((5,5), (0,0), colspan=1) # top left
    plt.subplots_adjust(hspace = 0, wspace=0)    # Remove whitespace
    
    ax1.plot([0,-1], color='black')    

    ax1.text(.18, -.78, a1_label, size=12) 
    ax1.text(.55, -.35, a2_label, size=12)    

    ax2 = plt.subplot2grid((5,5), (0,1), colspan=4) # top
    ax3 = plt.subplot2grid((5,5), (1,0), colspan=1, rowspan=4) #left
    ax4 = plt.subplot2grid((5,5), (1, 1), colspan=4, rowspan=4) #main contour
    ax3.invert_xaxis()
    ax4.yaxis.tick_right()
    ax4.xaxis.tick_bottom() #remove top xticks
    ax4.yaxis.set_label_position('right')
    
    ax4, contours = _gen2d3d(spec, ax=ax4, **contourkwds)
        
    # Bisecting line
    pvutil.diag_line(ax4)  
    
    # Fig is created by _gen2d in ax4 _gen2d3d
    fig = plt.gcf()
      
    # Hide axis labels 
    for ax in [ax2, ax3]:
        if grid:
            pvutil.hide_axis(ax, axis='both', axislabel=True, ticklabels=True)
        else:
            pvutil.hide_axis(ax, axis='both', hide_everything = True)
            
    pvutil.hide_axis(ax1, axis='both', hide_everything=True)
  
    #plt.colorbar() doesn't work
    # Handles its own colorbar (See links below; important)
   # http://stackoverflow.com/questions/13784201/matplotlib-2-subplots-1-colorbar
   # http://matplotlib.org/api/colorbar_api.html#matplotlib.colorbar.make_axes
    if cbar:
        if cbar in ['left', 'right', 'top', 'bottom']:
        # if bottom or right, should repad this
            location = cbar
        else:
            location = 'top'
        cax,kw = mplcbar.make_axes([ax1, ax2, ax3, ax4], 
                                   location=location,
                                   pad = 0.05,
                                   aspect = 30, #make skinnier
                                   shrink=0.75) 
        
        cb = fig.colorbar(contours, cax=cax,**kw)# ticks=[0,zz.max().max()], **kw)
        cb.locator = mplticker.MaxNLocator(nbins=cbar_nticks+1) #Cuts off one usually
        cb.set_label(spec.iunit)        
        cb.update_ticks()


    #ax1 will take care of itself in contour
    if grid:
        if grid == True:
            ax2.grid()
            ax3.grid()
  
        else:
            ax2.grid(color=grid)
            ax3.grid(color=grid)

    fig.suptitle(title, fontsize='large') # Still overpads
    return (ax1, ax2, ax3, ax4)
Beispiel #4
0
def _corr2d4fig(spec,
                a1_label=r'$\bar{A}(\nu_1)$',
                a2_label=r'$\bar{A}(\nu_2)$',
                **contourkwds):
    """ Abstract layout for 2d correlation analysis plot.  
    
    **contourkwds
        Passed directly to _gencontour; includes keywords like xlabel, ylabel
        and so forth.
    """

    # Maybe this should take X, Y, Z not ts

    #fig, ax #how to handle these in general 2d
    # Maybe it's helpful to have args for top plots (ie ax1,2,3)

    title = contourkwds.pop('title', '')
    cbar = contourkwds.pop('cbar', False)
    grid = contourkwds.setdefault('grid',
                                  True)  #Adds grid to plot and side plots

    # REFACTOR THIS
    cbar_nticks = 5

    # This will create a fig
    ax1 = plt.subplot2grid((5, 5), (0, 0), colspan=1)  # top left
    plt.subplots_adjust(hspace=0, wspace=0)  # Remove whitespace

    ax1.plot([0, -1], color='black')

    ax1.text(.18, -.78, a1_label, size=12)
    ax1.text(.55, -.35, a2_label, size=12)

    ax2 = plt.subplot2grid((5, 5), (0, 1), colspan=4)  # top
    ax3 = plt.subplot2grid((5, 5), (1, 0), colspan=1, rowspan=4)  #left
    ax4 = plt.subplot2grid((5, 5), (1, 1), colspan=4, rowspan=4)  #main contour
    ax3.invert_xaxis()
    ax4.yaxis.tick_right()
    ax4.xaxis.tick_bottom()  #remove top xticks
    ax4.yaxis.set_label_position('right')

    ax4, contours = _gen2d3d(spec, ax=ax4, **contourkwds)

    # Bisecting line
    pvutil.diag_line(ax4)

    # Fig is created by _gen2d in ax4 _gen2d3d
    fig = plt.gcf()

    # Hide axis labels
    for ax in [ax2, ax3]:
        if grid:
            pvutil.hide_axis(ax, axis='both', axislabel=True, ticklabels=True)
        else:
            pvutil.hide_axis(ax, axis='both', hide_everything=True)

    pvutil.hide_axis(ax1, axis='both', hide_everything=True)

    #plt.colorbar() doesn't work
    # Handles its own colorbar (See links below; important)
    # http://stackoverflow.com/questions/13784201/matplotlib-2-subplots-1-colorbar
    # http://matplotlib.org/api/colorbar_api.html#matplotlib.colorbar.make_axes
    if cbar:
        if cbar in ['left', 'right', 'top', 'bottom']:
            # if bottom or right, should repad this
            location = cbar
        else:
            location = 'top'
        cax, kw = mplcbar.make_axes(
            [ax1, ax2, ax3, ax4],
            location=location,
            pad=0.05,
            aspect=30,  #make skinnier
            shrink=0.75)

        cb = fig.colorbar(contours, cax=cax,
                          **kw)  # ticks=[0,zz.max().max()], **kw)
        cb.locator = mplticker.MaxNLocator(nbins=cbar_nticks +
                                           1)  #Cuts off one usually
        cb.set_label(spec.iunit)
        cb.update_ticks()

    #ax1 will take care of itself in contour
    if grid:
        if grid == True:
            ax2.grid()
            ax3.grid()

        else:
            ax2.grid(color=grid)
            ax3.grid(color=grid)

    fig.suptitle(title, fontsize='large')  # Still overpads
    return (ax1, ax2, ax3, ax4)