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


Python pyplot.barh方法代码示例

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


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

示例1: plot_preds

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def plot_preds(image, preds):
    """Displays image and the top-n predicted probabilities in a bar graph
    Args:
        image: PIL image
        preds: list of predicted labels and their probabilities
    """
    
    """# For Spyder
    plt.imshow(image)
    plt.axis('off')"""

    plt.figure()
    labels = ("cat", "dog")
    plt.barh([0, 1], preds, alpha=0.5)
    plt.yticks([0, 1], labels)
    plt.xlabel('Probability')
    plt.xlim(0,1.01)
    plt.tight_layout()
    plt.savefig('out.png') 
开发者ID:DhavalThkkar,项目名称:Transfer-Learning,代码行数:21,代码来源:predict.py

示例2: plot_bar_chart

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def plot_bar_chart(self, data):
        x = []
        y = []
        for item in data:
            y.append(item['count'])
            x.append(item['Implemented_by_partial_function'])
        plt.barh(x, y)
        plt.title("Top apis", fontsize=10)
        plt.xlabel("Number of API Calls", fontsize=8)
        plt.xticks([])
        plt.ylabel("Partial function", fontsize=8)
        plt.tick_params(axis='y', labelsize=8)
        for i, j in zip(y, x):
            plt.text(i, j, str(i), clip_on=True, ha='center',va='center', fontsize=8)
        plt.tight_layout()
        buf = BytesIO()
        plt.savefig(buf, format='png')
        image_base64 = base64.b64encode(buf.getvalue()).decode('utf-8').replace('\n', '')
        buf.close()
        # Clear the previous plot.
        plt.gcf().clear()
        return image_base64 
开发者ID:OpenBankProject,项目名称:API-Manager,代码行数:24,代码来源:views.py

示例3: draw_one

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def draw_one(self, xls, title, color):
        title = '{} ({})'.format(title, xls.columns[0])
        column_a = xls[xls.columns[0]]
        column_c = xls[xls.columns[2]]

        ticks = [column_a[x] for x in range(3, 16)]
        kbps = [self.float2(column_c[x]) for x in range(3, 16)]
        plt.barh(range(16 - 3), kbps, height=0.2, color=color, alpha=0.8)
        plt.yticks(range(16 - 3), ticks)
        plt.xlim(0, max(kbps) * 1.2)
        plt.xlabel("Speed")
        plt.title(title)
        for x, y in enumerate(kbps):
            plt.text(y + 1000, x - 0.1, '%s KB/s' % y)

        plt.show() 
开发者ID:RainMark,项目名称:oxfs,代码行数:18,代码来源:iozone_xls_to_graph.py

示例4: plot_topconsumer_bar_chart

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def plot_topconsumer_bar_chart(self, data):
        x = []
        y = []
        for item in data:
            y.append(item['count'])
            x.append(item['app_name'])
        plt.barh(x, y)
        plt.title("Top consumers", fontsize=10)
        plt.xlabel("Number of API Calls", fontsize=8)
        plt.xticks([])
        plt.ylabel("Consumers", fontsize=8)
        plt.tick_params(axis='y', labelsize=8)
        for i, j in zip(y, x):
            plt.text(i, j, str(i), clip_on=True, ha='center',va='center', fontsize=8)
        plt.tight_layout()
        buf = BytesIO()
        plt.savefig(buf, format='png')
        image_base64 = base64.b64encode(buf.getvalue()).decode('utf-8').replace('\n', '')
        buf.close()
        # Clear the previous plot.
        plt.gcf().clear()
        return image_base64 
开发者ID:OpenBankProject,项目名称:API-Manager,代码行数:24,代码来源:views.py

示例5: plot_parameter_statistic

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def plot_parameter_statistic(model, layer_types=['Dense', 'Conv2D'], trainable=True, non_trainable=False, outputs=False):
    parameter_count = []
    names = []
    for l in model.layers:
        if l.__class__.__name__ not in layer_types:
            continue
        count = 0
        if outputs:
            count += np.sum([np.sum([np.prod(s[1:]) for s in n.output_shapes]) for n in l._inbound_nodes])
        if trainable:
            count += np.sum([K.count_params(p) for p in set(l.trainable_weights)])
        if non_trainable:
            count += np.sum([K.count_params(p) for p in set(l.non_trainable_weights)])
        parameter_count.append(count)
        names.append(l.name)
    
    y = range(len(names))
    plt.figure(figsize=[12,max(len(y)//4,1)])
    plt.barh(y, parameter_count, align='center')
    plt.yticks(y, names)
    plt.ylim(y[0]-1, y[-1]+1)
    ax = plt.gca()
    ax.invert_yaxis()
    ax.xaxis.tick_top()
    plt.show() 
开发者ID:mogoweb,项目名称:aiexamples,代码行数:27,代码来源:model_utils.py

示例6: plot_dsc

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def plot_dsc(dsc_dist):
    y_positions = np.arange(len(dsc_dist))
    dsc_dist = sorted(dsc_dist.items(), key=lambda x: x[1])
    values = [x[1] for x in dsc_dist]
    labels = [x[0] for x in dsc_dist]
    labels = ["_".join(l.split("_")[1:-1]) for l in labels]
    fig = plt.figure(figsize=(12, 8))
    canvas = FigureCanvasAgg(fig)
    plt.barh(y_positions, values, align="center", color="skyblue")
    plt.yticks(y_positions, labels)
    plt.xticks(np.arange(0.0, 1.0, 0.1))
    plt.xlim([0.0, 1.0])
    plt.gca().axvline(np.mean(values), color="tomato", linewidth=2)
    plt.gca().axvline(np.median(values), color="forestgreen", linewidth=2)
    plt.xlabel("Dice coefficient", fontsize="x-large")
    plt.gca().xaxis.grid(color="silver", alpha=0.5, linestyle="--", linewidth=1)
    plt.tight_layout()
    canvas.draw()
    plt.close()
    s, (width, height) = canvas.print_to_buffer()
    return np.fromstring(s, np.uint8).reshape((height, width, 4)) 
开发者ID:mateuszbuda,项目名称:brain-segmentation-pytorch,代码行数:23,代码来源:inference.py

示例7: render

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def render(self):
        """ Prepare data for plotting
        """

        # init figure
        self.fig, self.ax = plt.subplots()
        self.ax.yaxis.grid(False)
        self.ax.xaxis.grid(True)

        # assemble colors
        colors = []
        for pkg in self.packages:
            colors.append(pkg.color)

        self.barlist = plt.barh(self.yPos, list(self.durations),
                                left=self.start,
                                align='center',
                                height=.5,
                                alpha=1,
                                color=colors)

        # format plot
        self.format()
        self.add_milestones()
        self.add_legend() 
开发者ID:stefanSchinkel,项目名称:gantt,代码行数:27,代码来源:gantt.py

示例8: altPlotFeaturesImportance

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def altPlotFeaturesImportance(X,y,featureNames,dataName):
    "http://nbviewer.ipython.org/github/cs109/2014/blob/master/homework-solutions/HW5-solutions.ipynb"
    clf = RandomForestClassifier(n_estimators=50)

    clf.fit(X,y)
    importance_list = clf.feature_importances_
    # name_list = df.columns #ORIG
    name_list=featureNames

    importance_list, name_list = zip(*sorted(zip(importance_list, name_list)))
    plt.barh(range(len(name_list)),importance_list,align='center')
    plt.yticks(range(len(name_list)),name_list)
    plt.xlabel('Relative Importance in the Random Forest')
    plt.ylabel('Features')
    plt.title('%s \n Relative Feature Importance' %(dataName))
    plt.grid('off')
    plt.ion()
    plt.show() 
开发者ID:ddofer,项目名称:ProFET,代码行数:20,代码来源:VisualizeBestFeatures.py

示例9: draw_bar

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def draw_bar(labels,quants,indicate_path,xlabel,ylabel,title):
    width=0.35
    plt.figure(figsize=(8,(width+0.1)*len(quants)), dpi=300)
    # Bar Plot
    plt.cla()
    plt.clf()
    plt.barh(range(len(quants)),quants,tick_label=labels)
    plt.grid(True)
    plt.title(title)
    plt.xlabel(xlabel)
    plt.ylabel(ylabel)
    plt.savefig(indicate_path)
    plt.close() 
开发者ID:kiharalab,项目名称:DOVE,代码行数:15,代码来源:Show.py

示例10: generate_city_pic

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def generate_city_pic(self, city_data):
        """
        生成城市数据图片
        因为plt在子线程中执行会出现自动弹出弹框并阻塞主线程的行为,plt行为均放在主线程中
        :param data:
        :return:
        """
        font = {'family': ['xkcd', 'Humor Sans', 'Comic Sans MS'],
                'weight': 'bold',
                'size': 12}
        matplotlib.rc('font', **font)
        cities = city_data['cities']
        city_people = city_data['city_people']

        # 绘制「性别分布」柱状图
        plt.barh(range(len(cities)), width=city_people, align='center', color=self.bar_color, alpha=0.8)
        # 添加轴标签
        plt.xlabel(u'Number of People')
        # 添加标题
        plt.title(u'Top %d Cities of your friends distributed' % len(cities), fontsize=self.title_font_size)
        # 添加刻度标签
        plt.yticks(range(len(cities)), cities)
        # 设置X轴的刻度范围
        plt.xlim([0, city_people[0] * 1.1])

        # 为每个条形图添加数值标签
        for x, y in enumerate(city_people):
            plt.text(y + len(str(y)), x, y, ha='center')

        # 显示图形
        plt.savefig(ALS.result_path + '/4.png')
        # todo 如果调用此处的关闭,就会导致应用本身也被关闭
        # plt.close()
        # plt.show() 
开发者ID:newbietian,项目名称:WxConn,代码行数:36,代码来源:main.py

示例11: draw_compare

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def draw_compare(self):
        xls = self.oxfs_xls
        column_a = xls[xls.columns[0]]
        column_c = xls[xls.columns[2]]

        oxfs_ticks = [column_a[x] + '- oxfs' for x in range(3, 16)]
        oxfs_kbps = [self.float2(column_c[x]) for x in range(3, 16)]

        xls = self.sshfs_xls
        column_a = xls[xls.columns[0]]
        column_c = xls[xls.columns[2]]

        sshfs_ticks = [column_a[x] + '- sshfs' for x in range(3, 16)]
        sshfs_kbps = [self.float2(column_c[x]) for x in range(3, 16)]

        ticks = []
        kbps = []
        for i in range(0, len(oxfs_kbps)):
            ticks.append(oxfs_ticks[i])
            ticks.append(sshfs_ticks[i])
            kbps.append(oxfs_kbps[i])
            kbps.append(sshfs_kbps[i])

        barlist = plt.barh(range(len(kbps)), kbps, height=0.3, color='coral', alpha=0.8)
        for bar in barlist[1::2]:
            bar.set_color('slateblue')
        plt.yticks(range(len(ticks)), ticks)
        plt.xlim(0, max(kbps) * 1.2)
        for x, y in enumerate(kbps):
            plt.text(y + 1000, x - 0.1, '%s KB/s' % y)

        title = 'Oxfs Vs Sshfs ({})'.format(xls.columns[0])
        plt.title(title)
        plt.xlabel("Speed")

        plt.show() 
开发者ID:RainMark,项目名称:oxfs,代码行数:38,代码来源:iozone_xls_to_graph.py

示例12: plot_performance

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def plot_performance(perf, kmax = 100, prec_type = 'LCS_HEIGHT', clip_ahp = None):
    
    import matplotlib.pyplot as plt
    
    plt.figure()
    plt.xlabel('k')
    plt.ylabel('Hierarchical Precision')
    plt.xlim(0, kmax)
    plt.ylim(0, 1)
    plt.grid()
    
    min_prec = 1.0
    for lbl, metrics in perf.items():
        precs = [metrics['P@{} ({})'.format(k, prec_type)] for k in range(1, kmax+1)]
        plt.plot(np.arange(1, kmax + 1), precs, label = lbl)
        min_prec = min(min_prec, min(precs))
    
    min_prec = np.floor(min_prec * 20) / 20
    if min_prec >= 0.3:
        plt.ylim(min_prec, 1)
    
    plt.legend(fontsize = 'x-small')
    
    
    plt.figure()
    plt.xlabel('Mean Average Hierarchical Precision')
    plt.yticks([])
    plt.grid(axis = 'x')
    
    for i, (lbl, metrics) in enumerate(perf.items()):
        mAHP = metrics['AHP{} ({})'.format('@{}'.format(clip_ahp) if clip_ahp else '', prec_type)]
        plt.barh(i + 0.5, mAHP, 0.8)
        plt.text(0.01, i + 0.5, lbl, verticalalignment = 'center', horizontalalignment = 'left', color = 'white', fontsize = 'small')
        plt.text(mAHP - 0.01, i + 0.5, '{:.1%}'.format(mAHP), verticalalignment = 'center', horizontalalignment = 'right', color = 'white')
    
    
    plt.show() 
开发者ID:cvjena,项目名称:semantic-embeddings,代码行数:39,代码来源:evaluate_retrieval.py

示例13: barHonGraphics

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def barHonGraphics(xLabel,yLabel,xValueList,yValueList,graphicTitle='图例',xWidth=0.5):
    plt.barh(numpy.arange(len(xValueList)), yValueList, alpha=0.4)
    plt.yticks(numpy.arange(len(xValueList)), xValueList,fontproperties=font_set)
    plt.xlabel(yLabel,fontproperties=font_set)
    plt.ylabel(xLabel,fontproperties=font_set)
    plt.title(graphicTitle,fontproperties=font_set)

    plt.show()
	
#折线图:蓝色粗线 
开发者ID:ankanch,项目名称:tieba-zhuaqu,代码行数:12,代码来源:graphicsData.py

示例14: plot_feature_split_proportions

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def plot_feature_split_proportions(model: SklearnModel, ax=None):
    if ax is None:
        _, ax = plt.subplots(1, 1)
    proportions = feature_split_proportions(model)

    y_pos = np.arange(len(proportions))
    name, count = list(proportions.keys()), list(proportions.values())
    props = pd.DataFrame({"name": name, "counts": count}).sort_values("name", ascending=True)
    plt.barh(y_pos, props.counts, align='center', alpha=0.5)
    plt.yticks(y_pos, props.name)
    plt.xlabel('Proportion of all splits')
    plt.ylabel('Feature')
    plt.title('Proportion of Splits Made on Each Variable')
    return ax 
开发者ID:JakeColtman,项目名称:bartpy,代码行数:16,代码来源:features.py

示例15: plot

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import barh [as 别名]
def plot(counts):
    labels = map(lambda x: x[0], counts)
    values = map(lambda y: y[1], counts)
    plt.barh(range(len(values)), values, color='green')
    plt.yticks(range(len(values)), labels)
    plt.show() 
开发者ID:PacktPublishing,项目名称:big-data-analytics,代码行数:8,代码来源:JupyterNotebook.py


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