當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。