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


Python Plot.set_up_plot_grid方法代码示例

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


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

示例1: Session

# 需要导入模块: from plot import Plot [as 别名]
# 或者: from plot.Plot import set_up_plot_grid [as 别名]

#.........这里部分代码省略.........
        if pdf is not None:
            parameters = pdf.choose_parameters()
            m = Menu(options=['mean and standard deviation',
                              'equal-tail limits',
                              'upper limit',
                              'lower limit'], 
                     exit_str=None, header='Choose statistics to compute:')
            m.get_choice()
            pdf.compute_1d_stats(parameters, stats=m.choice)

    def set_up_plot(self, settings=None):
        self.plot = Plot()
        if settings is not None:
            for key in settings:
                self.plot.settings[key] = settings[key]
        self.settings['plot'] = self.plot.settings
        n_rows = self.plot.settings['n_rows']
        n_cols = self.plot.settings['n_cols']
        if n_rows is not None and n_cols is not None:
            print '\nSetting up {0:d}x{1:d} plot.'.format(n_rows, n_cols)
        else:
            e_str = 'Number of {0:s} must be an integer > 0.'
            n_rows, n_cols = (0, 0)
            while n_rows < 1 or n_cols < 1:
                n_rows = utils.get_input_integer( \
                    '\nNumber of subplot rows?\n> ',
                    error_text=e_str.format('rows'))[0]
                n_cols = utils.get_input_integer( \
                    'Number of subplot columns?\n> ',
                    error_text=e_str.format('columns'))[0]
                if n_rows < 1 or n_cols < 1:
                    print 'Must have > 0 rows and columns.'

        self.plot.set_up_plot_grid(n_rows, n_cols)
        #self.plot.plot_grid.tight_layout(self.plot.figure)
        self.plot.figure.set_tight_layout(True)
        plt.show(block=False)
        print '(If you cannot see the plot, try changing the '
        print 'matplotlib backend. Current backend is ' + \
            plt.get_backend() + '.)'

    def save_plot(self):
        # add options to change file format, background color/transparency,
        # resolution, padding, etc.
        file_prefix = os.path.join('Plots', time.strftime('%Y-%m-%d'), 
                                   time.strftime('%Z.%H.%M.%S'))
        plot_file = file_prefix + '.eps'
        utils.check_path(plot_file)
        try:
            # bug in matplotlib 1.4.0 prevents this from working
            # (https://github.com/matplotlib/matplotlib/pull/3434)
            plt.savefig(plot_file, format='eps', bbox_inches='tight')
        except:
            plt.savefig(plot_file, format='eps')
        print '\nPlot saved as ' + plot_file
        plot_log_file = file_prefix + '.log'
        self.save_log(filename=plot_log_file)

    def change_plot(self):
        # options that apply to all subplots
        options = [('Change axis limits', self.plot.change_limits),
                   ('Change axis labels', self.plot.label_axes),
                   ('Add legend', self.plot.add_legend)]
        # change appearance of a PDF
        if self.pdf_exists():
            options.extend([('Change constraint color', 
开发者ID:mmortonson,项目名称:CosmoCombo,代码行数:70,代码来源:session.py


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