Exemple #1
0
 def twin_axes(cd):
     fig = mpl.gcf()
     fig.clf()
     
     # Get x coordinate values
     x = cd.patch.dimensions[0].centers
     
     # Draw fill plot
     depth_axes = fig.add_subplot(211)
     vel_axes = fig.add_subplot(212,sharex=depth_axes)     # the velocity scale
     kappa_axes = vel_axes.twinx()
     
     # Bottom layer
     depth_axes.fill_between(x,bathy(cd),eta_1(cd),color=plot.bottom_color)
     # Top Layer
     depth_axes.fill_between(x,eta_1(cd),eta_2(cd),color=plot.top_color)
     # Plot bathy
     depth_axes.plot(x,bathy(cd),'k',linestyle=plot.bathy_linestyle)
     # Plot internal layer
     depth_axes.plot(x,eta_2(cd),'k',linestyle=plot.internal_linestyle)
     # Plot surface
     depth_axes.plot(x,eta_1(cd),'k',linestyle=plot.surface_linestyle)
     
     # Remove ticks from top plot
     locs,labels = mpl.xticks()
     labels = ['' for i in xrange(len(locs))]
     mpl.xticks(locs,labels)
     
     depth_axes.set_title('Oscillatory Wind at t = %3.2f' % cd.t)
     depth_axes.set_xlim(xlimits)
     depth_axes.set_ylim(ylimits_depth)
     depth_axes.set_ylabel('Depth (m)')
     
     # Draw velocity and kappa plot
     
     # Bottom layer velocity
     bottom_layer = vel_axes.plot(cd.x,u_2(cd),'k-',label="Bottom Layer Velocity")
     # Top Layer velocity
     top_layer = vel_axes.plot(cd.x,u_1(cd),'b--',label="Top Layer velocity")
     
     # Kappa
     kappa_line = kappa_axes.plot(cd.x,kappa(cd),'r-.')
     kappa_axes.plot(cd.x,np.ones(cd.x.shape),'r:')
     
     plot.add_legend(vel_axes,'Kappa',color='r',linestyle='-.',location=4)
     vel_axes.set_xlim(xlimits)
     vel_axes.set_ylim(ylimits_velocities)
     kappa_axes.set_ylim(ylimits_kappa)
     vel_axes.set_title('')
     # vel_axes.set_title('Layer Velocities and Kappa')
     vel_axes.set_ylabel('Velocities (m/s)')
     kappa_axes.set_ylabel('Kappa')
     
     # This does not work on all versions of matplotlib
     try:
         mpl.subplots_adjust(hspace=0.1)
     except:
         pass
Exemple #2
0
    def twin_axes(cd):
        fig = mpl.gcf()
        fig.clf()

        # Get x coordinate values
        x = cd.patch.dimensions[0].centers

        # Draw velocity and kappa plot
        vel_axes = fig.add_subplot(111)  # the velocity scale
        # kappa_axes = vel_axes.twinx()              # the kappa scale

        # Bottom layer velocity
        bottom_layer = vel_axes.plot(x,
                                     u_2(cd),
                                     'k-',
                                     label="Bottom Layer Velocity")
        # Top Layer velocity
        top_layer = vel_axes.plot(x,
                                  u_1(cd),
                                  'b--',
                                  label="Top Layer velocity")

        if include_kappa:
            # Kappa
            kappa_line = kappa_axes.plot(x, kappa(cd), 'r-.', label="Kappa")
            kappa_axes.plot(x, np.ones(x.shape), 'r:')

        vel_axes.set_xlabel('km')
        mpl.xticks([-300e3, -200e3, -100e3, -30e3], [300, 200, 100, 30],
                   fontsize=15)

        for ref_line in bathy_ref_lines:
            vel_axes.plot([ref_line, ref_line], ylimits_velocities, 'k:')
        if include_kappa:
            vel_axes.set_title("Layer Velocities and Kappa at t = %4.1f s" %
                               cd.t)
        else:
            vel_axes.set_title("Layer Velocities at t = %4.1f s" % cd.t)
        vel_axes.set_ylabel('Velocities (m/s)')
        vel_axes.set_xlim(xlimits)
        vel_axes.set_ylim(ylimits_velocities)

        if include_kappa:
            plot.add_legend(vel_axes,
                            'Kappa',
                            location=3,
                            color='r',
                            linestyle='-.')
            kappa_axes.set_ylabel('Kappa')
            kappa_axes.set_ylim(ylimits_kappa)
        else:
            vel_axes.legend(loc=3)
        try:
            mpl.subplots_adjust(hspace=0.1)
        except:
            pass
Exemple #3
0
    def twin_axes(cd):
        fig = mpl.gcf()
        fig.clf()

        # Get x coordinate values
        x = cd.patch.dimensions[0].centers
        
        # Draw velocity and kappa plot
        vel_axes = fig.add_subplot(111)     # the velocity scale
        # kappa_axes = vel_axes.twinx()              # the kappa scale
        
        # Bottom layer velocity
        bottom_layer = vel_axes.plot(x,u_2(cd),'k-',label="Bottom Layer Velocity")
        # Top Layer velocity
        top_layer = vel_axes.plot(x,u_1(cd),'b--',label="Top Layer velocity")
        
        if include_kappa:
            # Kappa
            kappa_line = kappa_axes.plot(x,kappa(cd),'r-.',label="Kappa")
            kappa_axes.plot(x,np.ones(x.shape),'r:')

        vel_axes.set_xlabel('km')
        mpl.xticks([-300e3,-200e3,-100e3,-30e3],[300,200,100,30],fontsize=15)
        
        for ref_line in bathy_ref_lines:
            vel_axes.plot([ref_line,ref_line],ylimits_velocities,'k:')
        if include_kappa:
            vel_axes.set_title("Layer Velocities and Kappa at t = %4.1f s" % cd.t)
        else:
            vel_axes.set_title("Layer Velocities at t = %4.1f s" % cd.t)
        vel_axes.set_ylabel('Velocities (m/s)')
        vel_axes.set_xlim(xlimits)
        vel_axes.set_ylim(ylimits_velocities)

        if include_kappa:
            plot.add_legend(vel_axes,'Kappa',location=3,color='r',linestyle='-.')
            kappa_axes.set_ylabel('Kappa')
            kappa_axes.set_ylim(ylimits_kappa)
        else:
            vel_axes.legend(loc=3)
        try:
            mpl.subplots_adjust(hspace=0.1)
        except:
            pass