当前位置: 首页>>代码示例>>Python>>正文


Python ScalarFormatter.set_useOffset方法代码示例

本文整理汇总了Python中matplotlib.ticker.ScalarFormatter.set_useOffset方法的典型用法代码示例。如果您正苦于以下问题:Python ScalarFormatter.set_useOffset方法的具体用法?Python ScalarFormatter.set_useOffset怎么用?Python ScalarFormatter.set_useOffset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.ticker.ScalarFormatter的用法示例。


在下文中一共展示了ScalarFormatter.set_useOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ra_plot

# 需要导入模块: from matplotlib.ticker import ScalarFormatter [as 别名]
# 或者: from matplotlib.ticker.ScalarFormatter import set_useOffset [as 别名]
def ra_plot(array_dict, tcas_ra_array, tcas_ctl_array, tcas_up_array, tcas_down_array, 
            vert_ctl_array, sens_array, filename, orig, dest, tstart, tend):
    '''plot tcas: vertical speed + controls    '''
    import matplotlib.pyplot as plt
    from matplotlib.ticker import ScalarFormatter 
    formatter = ScalarFormatter(useOffset=False) 
    formatter.set_powerlimits((-8,8)) 
    formatter.set_scientific(False) 
    formatter.set_useOffset(0.0) 

    plt.figure(figsize=(15,15)) #set size in inches
    plt.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=0.5)
    
    # top time series plot
    axts    = plt.subplot2grid((8, 1), (0, 0), rowspan=2) #time series    
    axts.xaxis.set_major_formatter(formatter) 
    series_names = array_dict.keys()  #only first 4
    series_formats = ['k','r','g','b']    #color codes
    for i,nm in enumerate(series_names):
        ln=axts.plot(array_dict[nm], series_formats[i], alpha=0.45)
        plt.setp(ln, linewidth=2)
    leg = axts.legend(series_names, 'upper left', fancybox=True)
    leg.get_frame().set_alpha(0.5)
    axts.grid(True, color='gray')
    plt.title('Vertical Speed (fpm)')
    axts.autoscale(enable=False)
    
    # tcas ra
    ax_ra = plt.subplot2grid((8, 1), (2, 0), sharex=axts)     # 
    ra_states = tcas_ra_array.values_mapping.values()
    ra_states = [s.replace('Most Dangerous','') for s in ra_states]
    ra_array = tcas_ra_array.data 
    plot_mapped_array(plt, ax_ra, ra_states, ra_array, title="TCAS RA")

    # combined control
    ax_ctl = plt.subplot2grid((8, 1), (3, 0), sharex=axts)     # 
    ctl_states = tcas_ctl_array.values_mapping.values()
    ctl_states = [s.replace('Advisory','Advzy').replace('Corrective', 'Corr.') for s in ctl_states]
    ctl_array = tcas_ctl_array.data 
    plot_mapped_array(plt, ax_ctl, ctl_states, ctl_array, title="TCAS Combined Control")

    # up and down advisory
    ax_updown   = plt.subplot2grid((8, 1), (4, 0), sharex=axts, rowspan=2)  
    up_states   = [' ']+tcas_up_array.values_mapping.values()
    down_states = [' ']+tcas_down_array.values_mapping.values()
    ud_states    = up_states + down_states
    
    def disp_state(st):
        st = st.replace('Descent Corrective','Desc Corr.')
        st = st.replace('Descend ','Desc>')
        st = st.replace('Advisory','Advzy').replace('advisory','Advzy')
        st = st.replace("Don't Climb ","Don't Climb>")
        return st

    ud_states = [ disp_state(s) for s in ud_states]
    plt.yticks( np.arange(len(ud_states)), ud_states )   

    up_array = tcas_up_array.data + 1 # adjust for display
    ax_updown.plot(up_array, 'g')
    down_array = tcas_down_array.data + len(up_states)+1 # adjust for display
    ax_updown.plot(down_array, 'r')
    ax_updown.grid(True, color='gray')
    plt.ylim(0, len(up_states) + len(down_states)) 
    plt.title('TCAS Up/Down Advisory')
    
    # vertical control
    ax_vert   = plt.subplot2grid((8, 1), (6, 0), sharex=axts)  
    vert_states   = vert_ctl_array.values_mapping.values()    
    vert_states = [' ']+[s.replace("Advisory is not one of the following types",'NA') for s in vert_states]
    vert_array = vert_ctl_array.data + 1
    plot_mapped_array(plt, ax_vert, vert_states, vert_array, title="TCAS Vertical Control")
    
    #sensitivity mode    
    ax_sens   = plt.subplot2grid((8, 1), (7, 0), sharex=axts)  
    sens_states   = sens_array.values_mapping.values()    
    sens_states = [' ']+[s.replace("SL = ",'') for s in sens_states]
    sens_arr = sens_array.data + 1 # adjust for display
    plot_mapped_array(plt, ax_sens, sens_states, sens_arr, title="TCAS Sensitivity Mode")

    plt.xlabel('time index')
    plt.xlim(tstart, tend) 
    plt.suptitle('TCAS RA: '+filename.value + '\n  '+orig.value['code']['icao']+'-'+dest.value['code']['icao']+ ' '+str(tstart)+':'+str(tend))
    return plt
开发者ID:catawbasam,项目名称:asias_fds_profiles,代码行数:85,代码来源:tcas_profile.py


注:本文中的matplotlib.ticker.ScalarFormatter.set_useOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。