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


Python Figure.invert方法代码示例

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


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

示例1: plot_init

# 需要导入模块: from matplotlib.figure import Figure [as 别名]
# 或者: from matplotlib.figure.Figure import invert [as 别名]
def plot_init(square=True, xs=6, aspect=1, left=0.22, bottom=0.11, right=0.02, top=0.02, wspace=0.2, hspace=0.02, fontsize=10, NO_GUI=False, use_tex=False, invert=False):
    """
    Wrapper for generating a plot window, contains input parameters for setting the 
    full window geometry and also handles toggling the GUI/interactive backend.
    
    NO_GUI should be set to True if your session has no X11 connection.    
    """
    import unicorn
    import matplotlib
    rc = matplotlib.rcParams
    
    #### If logged in to an external machine ("uni"), don't use GUI plotter
    if unicorn.hostname().startswith('uni') | NO_GUI:
        unicorn.plotting.USE_PLOT_GUI = False
    else:
        unicorn.plotting.USE_PLOT_GUI = True
    
    # plt.rcParams['font.family'] = 'serif'
    # plt.rcParams['font.serif'] = ['Times']
    plt.rcParams['patch.edgecolor'] = 'None'
    plt.rcParams['font.size'] = fontsize

    plt.rcParams['image.origin'] = 'lower'
    plt.rcParams['image.interpolation'] = 'nearest'

    if use_tex:
        plt.rcParams['text.usetex'] = True
        plt.rcParams['font.family'] = 'serif'
        plt.rcParams['font.serif'] = 'Times'
    
    #### White on black colormap
    if invert:

        if isinstance(invert, str):
            color = invert
        else:
            color = 'white'
        
        rc['lines.color'] = color
        rc['patch.edgecolor'] = color
        rc['text.color'] = color
        rc['axes.facecolor'] = 'black'
        rc['axes.edgecolor'] = color
        rc['axes.labelcolor'] = color
        rc['xtick.color'] = color
        rc['ytick.color'] = color
        rc['grid.color'] = color
        rc['figure.facecolor'] = 'black'
        rc['figure.edgecolor'] = 'black'
        rc['savefig.facecolor'] = 'black'
        rc['savefig.edgecolor'] = 'black'
    else:

        rc['lines.color'] = 'black'
        rc['patch.edgecolor'] = 'black'
        rc['text.color'] = 'black'
        rc['axes.facecolor'] = 'white'
        rc['axes.edgecolor'] = 'black'
        rc['axes.labelcolor'] = 'black'
        rc['xtick.color'] = 'black'
        rc['ytick.color'] = 'black'
        rc['grid.color'] = 'black'
        rc['figure.facecolor'] = 'white'
        rc['figure.edgecolor'] = 'white'
        rc['savefig.facecolor'] = 'white'
        rc['savefig.edgecolor'] = 'white'
        
    if square:
        #xs=5
        lrbt = np.array([left,right,bottom,top])*5./xs     
        ys = (1-lrbt[1]-lrbt[0])/(1-lrbt[3]-lrbt[2])*xs*aspect
        lrbt[[2,3]] /= aspect

        if USE_PLOT_GUI:
            fig = plt.figure(figsize=(xs,ys), dpi=100)
        else:
            fig = Figure(figsize=(xs,ys), dpi=100)
            
        fig.subplots_adjust(left=lrbt[0], bottom=lrbt[2], right=1-lrbt[1], top=1-lrbt[3], wspace=wspace, hspace=hspace)
            
    else:
        if USE_PLOT_GUI:
            fig = plt.figure(figsize=(7,5), dpi=100)
        else:
            fig = Figure(figsize=(7,5), dpi=100)
            
        fig.subplots_adjust(wspace=wspace, hspace=hspace,left=0.10,
                        bottom=0.10,right=0.99,top=0.97)        
    
    if invert:
        fig.invert = True
    else:
        fig.invert = False
        
    return fig
开发者ID:gbrammer,项目名称:unicorn,代码行数:97,代码来源:plotting.py


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