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


Python pyplot.figtext方法代碼示例

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


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

示例1: scatter_fret_nd_na

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figtext [as 別名]
def scatter_fret_nd_na(d, i=0, show_fit=False, no_text=False, gamma=1.,
                       **kwargs):
    """Scatterplot of FRET versus gamma-corrected burst size."""
    default_kwargs = dict(mew=0, ms=3, alpha=0.3, color=blue)
    default_kwargs.update(**kwargs)
    plot(d.E[i], gamma*d.nd[i]+d.na[i], 'o', **default_kwargs)
    xlabel("FRET Efficiency (E)")
    ylabel("Burst size (#ph)")
    if show_fit:
        _fitted_E_plot(d, i, F=1., no_E=no_text, ax=gca())
        if i == 0 and not no_text:
            plt.figtext(0.4, 0.01, _get_fit_E_text(d), fontsize=14) 
開發者ID:tritemio,項目名稱:FRETBursts,代碼行數:14,代碼來源:burst_plot.py

示例2: update_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figtext [as 別名]
def update_plot(self):

        layers = self.get_trainable_layers()

        for layer in layers:
            for param in self.parameters:
                weights = [w for w in layer.weights if
                           param in w.name.split("_")]

                if len(weights) == 0:
                    continue

                val = numpy.column_stack((w.get_value() for w in weights))
                name = layer.name + "_" + param
                self.layers_stats[name]["values"] = val.ravel()
                for s in self.stats:
                    if s == "raster":
                        if len(val.shape) > 2:
                            val = val.reshape((val.shape[0], -1), order='F')
                        self.layers_stats[name][s] = val
                        # self.fig.colorbar()
                    else:
                        self.layers_stats[name][s].append(
                            getattr(numpy, s)(val))

        plt.figtext(.02, .02, get_model_desc(self.model), wrap=True,
                    fontsize=8)
        self.fig.tight_layout()
        self.fig.subplots_adjust(bottom=.2)
        self.fig.canvas.draw()
        self.fig.canvas.flush_events() 
開發者ID:cbaziotis,項目名稱:keras-utilities,代碼行數:33,代碼來源:callbacks.py

示例3: _skipplot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figtext [as 別名]
def _skipplot(self, key):
        import matplotlib.pyplot as plt
        fig = plt.figure()
        plt.figtext(0.5, 0.5, 'No data available.', ha='center')
        fig.set_size_inches(*self.size_inches)
        if self.autosave:
            self.savefig(fig, key)
            plt.close(fig)
            fig = None
        print('Skipped Plot.')
        return fig 
開發者ID:skuschel,項目名稱:postpic,代碼行數:13,代碼來源:plotter_matplotlib.py

示例4: plot_frame

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figtext [as 別名]
def plot_frame(settings, organisms, foods, gen, time):
    fig, ax = plt.subplots()
    fig.set_size_inches(9.6, 5.4)

    plt.xlim([settings['x_min'] + settings['x_min'] * 0.25, settings['x_max'] + settings['x_max'] * 0.25])
    plt.ylim([settings['y_min'] + settings['y_min'] * 0.25, settings['y_max'] + settings['y_max'] * 0.25])

    # PLOT ORGANISMS
    for organism in organisms:
        plot_organism(organism.x, organism.y, organism.r, ax)

    # PLOT FOOD PARTICLES
    for food in foods:
        plot_food(food.x, food.y, ax)

    # MISC PLOT SETTINGS
    ax.set_aspect('equal')
    frame = plt.gca()
    frame.axes.get_xaxis().set_ticks([])
    frame.axes.get_yaxis().set_ticks([])

    plt.figtext(0.025, 0.95,r'GENERATION: '+str(gen))
    plt.figtext(0.025, 0.90,r'T_STEP: '+str(time))

    plt.savefig(str(gen)+'-'+str(time)+'.png', dpi=100)
##    plt.show() 
開發者ID:nathanrooy,項目名稱:evolving-simple-organisms,代碼行數:28,代碼來源:organism_v1.py

示例5: classify_one_image

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figtext [as 別名]
def classify_one_image(self, imgf,
            classes=['afraid', 'angry', 'disgusted', 'happy', 'neutral', 'sad', 'surprised']):
        normalize = transforms.Normalize(mean=[0.485, 0.456, 0.406],
                                         std=[0.229, 0.224, 0.225])
        transf = transforms.Compose([
                transforms.Scale(256),
                transforms.CenterCrop(224),
                transforms.ToTensor(),
                normalize,
        ])
        # Face detection
        args = {}
        args['threshold'] = 0.0
        args['window'] = False
        args['ignore_multi'] = True
        args['grow'] = 10 
        args['resize'] = True
        args['row_resize'] = 512
        args['col_resize'] = 512
        args['min_proportion'] = 0.1
        with tempfile.TemporaryDirectory() as tempdir:
            args['o'] = tempdir
            face_detector.transform(extract_faces.AttributeDict(args), [imgf])
            cropped = Image.open(tempdir + '/' + os.path.basename(imgf))
        cropped = transf(cropped)
        
        input_var = Variable(cropped.view(1, *cropped.shape))

        if torch.cuda.is_available():
            input_var = input_var.cuda()

        output = self.model.forward(input_var).cpu().data.numpy()
        softmax = np.exp(output) / np.sum(np.exp(output))
        clss = np.argmax(softmax)
        fig = plt.figure()
        plt.imshow(Image.open(imgf))
        fig.subplots_adjust(bottom=0.2)
        plt.figtext(0.1, 0.05, ', '.join(classes))
        plt.figtext(0.1, 0.10, ', '.join(['{:.3}'.format(a) for a in softmax.reshape(-1)]))
        plt.title(classes[clss])
        plt.show() 
開發者ID:co60ca,項目名稱:EmotionNet2,代碼行數:43,代碼來源:emotionnet.py

示例6: heatmap_full

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figtext [as 別名]
def heatmap_full(single_env, cmap="Blues", cols=None):
    # Figure layout calculations
    if cols is None:
        cols = single_env.columns

    cbar_width_in = 0.41
    reserved = {  # in inches
        "left": 0.605,  # for y-axis
        "top": 0.28,  # for title
        "bottom": 0.49,  # for x-axis
        "right": cbar_width_in + 0.02,  # for color bar plus margin
    }

    reserved_height = reserved["top"] + reserved["bottom"]
    width, nominal_height = plt.rcParams.get("figure.figsize")
    portion_for_heatmap = nominal_height - reserved_height
    # We want height to vary depending on number of labels. Take figure size as specifying the
    # height for a 'typical' figure with 6 rows.
    height_per_row = nominal_height * portion_for_heatmap / 6
    num_rows = len(pd.unique(single_env.index.get_level_values(0)))
    height_for_heatmap = height_per_row * max(num_rows, 4)

    height = reserved_height + height_for_heatmap
    gridspec_kw = {
        "top": 1 - reserved["top"] / height,
        "bottom": reserved["bottom"] / height,
        "wspace": 0.05,
        "hspace": 0.05,
    }

    # Actually plot the heatmap
    subplot_wspace = 0.05 / width
    left = reserved["left"] / width
    max_right = 1 - reserved["right"] / width
    per_plot_width = (max_right - left) / len(cols)

    single_env *= 100 / num_episodes(single_env)  # convert to percentages
    fig = plt.figure(figsize=(width, height))
    for i, col in enumerate(cols):
        right = left + per_plot_width - subplot_wspace
        gridspec_kw.update({"left": left, "right": right})

        cbar = i == len(cols) - 1
        subplot_cbar_width = cbar_width_in / width if cbar else 0.0

        _pretty_heatmap(
            single_env, col, cmap, fig, gridspec_kw, cbar_width=subplot_cbar_width, yaxis=i == 0
        )

        if len(cols) > 1:
            mid_x = (left + right - subplot_cbar_width) / 2
            mid_y = (1 + gridspec_kw["top"]) / 2
            plt.figtext(
                mid_x, mid_y, col, va="center", ha="center", size=plt.rcParams.get("axes.titlesize")
            )

        left += per_plot_width

    return fig 
開發者ID:HumanCompatibleAI,項目名稱:adversarial-policies,代碼行數:61,代碼來源:util.py

示例7: draw_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import figtext [as 別名]
def draw_plot(self):
        self.fig.clf()

        layers = self.get_trainable_layers()
        height = len(self.layers_stats)
        width = len(self.stats) + 1

        plot_count = 1
        for layer in layers:
            for param in self.parameters:
                weights = [w for w in layer.weights if
                           param in w.name.split("_")]

                if len(weights) == 0:
                    continue

                val = numpy.column_stack((w.get_value() for w in weights))
                name = layer.name + "_" + param

                self.layers_stats[name]["values"] = val.ravel()
                ax = self.fig.add_subplot(height, width, plot_count)
                ax.hist(self.layers_stats[name]["values"], bins=50)
                ax.set_title(name, fontsize=10)
                ax.grid(True)
                ax.tick_params(labelsize=8)
                plot_count += 1

                for s in self.stats:
                    axs = self.fig.add_subplot(height, width, plot_count)

                    if s == "raster":
                        if len(val.shape) > 2:
                            val = val.reshape((val.shape[0], -1), order='F')
                        self.layers_stats[name][s] = val
                        m = axs.imshow(self.layers_stats[name][s],
                                       cmap='coolwarm',
                                       interpolation='nearest',
                                       aspect='auto', )  # aspect='equal'
                        cbar = self.fig.colorbar(mappable=m)
                        cbar.ax.tick_params(labelsize=8)
                    else:
                        self.layers_stats[name][s].append(
                            getattr(numpy, s)(val))
                        axs.plot(self.layers_stats[name][s])
                        axs.set_ylabel(s, fontsize="small")
                        axs.set_xlabel('epoch', fontsize="small")
                        axs.grid(True)

                    axs.set_title(name + " - " + s, fontsize=10)
                    axs.tick_params(labelsize=8)
                    plot_count += 1

        # plt.figtext(.1, .1, get_model_desc(self.model), wrap=True, fontsize=8)
        desc = get_model_desc(self.model)
        self.fig.text(.02, .02, desc, verticalalignment='bottom', wrap=True,
                      fontsize=8)
        self.fig.tight_layout()
        self.fig.subplots_adjust(bottom=.14)
        self.fig.canvas.draw()
        self.fig.canvas.flush_events() 
開發者ID:cbaziotis,項目名稱:keras-utilities,代碼行數:62,代碼來源:callbacks.py


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