當前位置: 首頁>>代碼示例>>Python>>正文


Python Plot.plot_2d_pdf方法代碼示例

本文整理匯總了Python中plot.Plot.plot_2d_pdf方法的典型用法代碼示例。如果您正苦於以下問題:Python Plot.plot_2d_pdf方法的具體用法?Python Plot.plot_2d_pdf怎麽用?Python Plot.plot_2d_pdf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在plot.Plot的用法示例。


在下文中一共展示了Plot.plot_2d_pdf方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Session

# 需要導入模塊: from plot import Plot [as 別名]
# 或者: from plot.Plot import plot_2d_pdf [as 別名]

#.........這裏部分代碼省略.........
                             self.change_pdf_color)])
        # options specific to 1D or 2D plots
        subplot_1d_exists = False
        subplot_2d_exists = False
        subplot_2d_has_multiple_contours = False
        for ax_row in self.plot.axes:
            for ax in ax_row:
                if hasattr(ax, 'parameters'):
                    if len(ax.parameters) == 1:
                        subplot_1d_exists = True
                    elif len(ax.parameters) == 2:
                        subplot_2d_exists = True
                        if len(ax.pdfs) > 1:
                            subplot_2d_has_multiple_contours = True
        if subplot_2d_has_multiple_contours:
            options.extend([('Change order of contour layers', 
                             self.plot.change_layer_order)])
        options = OrderedDict(options)
        m = Menu(options=options.keys(), exit_str='Cancel')
        m.get_choice()
        if m.choice != m.exit:
            options[m.choice]()
            #self.plot.plot_grid.tight_layout(self.plot.figure)
            self.plot.figure.set_tight_layout(True)
            plt.draw()

    def change_pdf_color(self):
        pdf = self.choose_pdf()
        if pdf is not None:
            pdf.set_color()
            if self.plot:
                for ax_row in self.plot.axes:
                    for ax in ax_row:
                        subplot_pdfs = self.plot.settings \
                            ['{0:d}.{1:d}'.format(ax.row, ax.col)] \
                            ['pdfs']
                        if pdf.name in subplot_pdfs:
                            self.plot_constraint(ax.row, ax.col, pdf=pdf)

    def plot_constraint(self, row=None, col=None, pdf=None, 
                        parameters=None, limits=None):
        if pdf is None:
            pdf = self.choose_pdf(require_data=True)
        if pdf is not None:
            ax = self.plot.select_subplot(row=row, col=col)
            if len(ax.pdfs) == 0:
                self.set_up_subplot(ax.row, ax.col, pdf, parameters, limits)
            if pdf.settings['color'] is None:
                pdf.set_color()
            n_dim = len(ax.parameters)
            if n_dim == 1:
                self.plot.plot_1d_pdf(ax, pdf)
            elif n_dim == 2:
                self.plot.plot_2d_pdf(ax, pdf)
            plt.draw()

    def set_up_subplot(self, row, col, pdf, parameters, limits):
        ax = self.plot.axes[row][col]
        ax_settings = self.plot.settings['{0:d}.{1:d}'.format(row, col)]
        if parameters is None:
            ax.parameters = pdf.choose_parameters()
        else:
            ax.parameters = parameters
        if len(ax.parameters) > 2:
            print 'Number of parameters must be 1 or 2.'
            self.set_up_subplot(row, col, pdf, parameters, limits)
        ax_settings['parameters'] = ax.parameters
        self.plot.change_limits(ax=ax, limits=limits)

    def pdf_exists(self):
        if len(self.pdfs) > 0:
            return True
        else:
            return False

    def pdf_without_chain_exists(self):
        answer = False
        for pdf in self.pdfs:
            if not pdf.has_mcmc():
                answer = True
        return answer

    def pdf_with_data_exists(self):
        answer = False
        for pdf in self.pdfs:
            if pdf.chain is not None:
                answer = True
        return answer

    def plot_exists(self):
        if self.plot:
            return True
        else:
            return False

    def plot_and_pdf_with_data_exist(self):
        if self.plot and self.pdf_with_data_exists():
            return True
        else:
            return False
開發者ID:mmortonson,項目名稱:CosmoCombo,代碼行數:104,代碼來源:session.py


注:本文中的plot.Plot.plot_2d_pdf方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。