pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

<small id='SoLLo'></small><noframes id='SoLLo'>

<tfoot id='SoLLo'></tfoot>
      <bdo id='SoLLo'></bdo><ul id='SoLLo'></ul>
      <i id='SoLLo'><tr id='SoLLo'><dt id='SoLLo'><q id='SoLLo'><span id='SoLLo'><b id='SoLLo'><form id='SoLLo'><ins id='SoLLo'></ins><ul id='SoLLo'></ul><sub id='SoLLo'></sub></form><legend id='SoLLo'></legend><bdo id='SoLLo'><pre id='SoLLo'><center id='SoLLo'></center></pre></bdo></b><th id='SoLLo'></th></span></q></dt></tr></i><div class="j9rhnjb" id='SoLLo'><tfoot id='SoLLo'></tfoot><dl id='SoLLo'><fieldset id='SoLLo'></fieldset></dl></div>
        <legend id='SoLLo'><style id='SoLLo'><dir id='SoLLo'><q id='SoLLo'></q></dir></style></legend>

      1. Seaborn Catplot 在條形圖上設置值

        Seaborn Catplot set values over the bars(Seaborn Catplot 在條形圖上設置值)
      2. <i id='p8Lxb'><tr id='p8Lxb'><dt id='p8Lxb'><q id='p8Lxb'><span id='p8Lxb'><b id='p8Lxb'><form id='p8Lxb'><ins id='p8Lxb'></ins><ul id='p8Lxb'></ul><sub id='p8Lxb'></sub></form><legend id='p8Lxb'></legend><bdo id='p8Lxb'><pre id='p8Lxb'><center id='p8Lxb'></center></pre></bdo></b><th id='p8Lxb'></th></span></q></dt></tr></i><div class="nltpbfx" id='p8Lxb'><tfoot id='p8Lxb'></tfoot><dl id='p8Lxb'><fieldset id='p8Lxb'></fieldset></dl></div>

              <bdo id='p8Lxb'></bdo><ul id='p8Lxb'></ul>

              <small id='p8Lxb'></small><noframes id='p8Lxb'>

              <tfoot id='p8Lxb'></tfoot>

              <legend id='p8Lxb'><style id='p8Lxb'><dir id='p8Lxb'><q id='p8Lxb'></q></dir></style></legend>

                    <tbody id='p8Lxb'></tbody>
                • 本文介紹了Seaborn Catplot 在條形圖上設置值的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我像這樣在seaborn中繪制了一個catplot

                  將 seaborn 導入為 sns將熊貓導入為 pd數據= {'年':[2016、2013、2014、2015、2016、2013、2014、2015、2016、2013、2014、2015、2016、2013、2014、2015、2016、2013、2014、2015]geo_name': ['Michigan', 'Michigan', 'Michigan', 'Michigan', 'Washtenaw County, MI', 'Washtenaw County, MI', 'Washtenaw County, MI', 'Washtenaw County, MI', 'Ann密歇根州阿伯市"、密歇根州安娜堡"、密歇根州安娜堡"、密歇根州安娜堡"、賓夕法尼亞州費城"、賓夕法尼亞州費城"、賓夕法尼亞州費城"、賓夕法尼亞州費城"、'密歇根州安娜堡市都會區', '密歇根州安娜堡市都會區', '密歇根州安娜堡市都會區', '密歇根州安娜堡市都會區'], 'geo': ['04000US26', '04000US26','04000us26','04000us26','05000us26161','05000us26161','05000us26161','16000us2603000','16000us2603000','16000us2603000','16000us4260000','16000us4260000','16000US4260000','16000US4260000','16000US42600','16000US42600','16000US42600','16000US42600','16000US42600','16000US42600','16000US4260000''16000US4260000'','16000US4260000','31000US11460','31000US11460','31000US11460','31000us11460','收入':[50803.0,48411.0,49087.0,49576.0,62484.0,59055.0,60805.0,61003.0,57697.0,59003.0,56835.0,55990.0,39770.0,37192.0,37460.0,38253.0,62484.0,59055.0,60805.0,61003.0],收入_MOE":[162.0,163.0,192.0,186.0,984.0,985.0,958.0,901.0,2046.0,1688.0,1320.0,1259.0,567.0,424.0、430.0、511.0、984.0、985.0、958.0、901.0]}df = pd.DataFrame(數據)g = sns.catplot(x='year', y='income', data=df, kind='bar', hue='geo_name', legend=True)g.fig.set_size_inches(15,8)g.fig.subplots_adjust(top=0.81,right=0.86)

                  我得到如下所示的輸出

                  我想在 K 表示的頂部添加每個條的值.例如在 2013 中,Michigan 的欄位于 48411 所以我想在上面添加值 48.4K酒吧.對于所有的酒吧也是如此.

                  解決方案

                  更新至matplotlib v3.4.2

                  • 使用

                    對于單個或多個地塊

                    g = sns.catplot(x='year', y='income', data=df, kind='bar', col='geo_name',col_wrap=3,圖例=真)g.fig.set_size_inches(15, 8)g.fig.subplots_adjust(top=0.9)g.fig.suptitle('帶注釋的條形計數')# 遍歷軸對于 g.axes.ravel() 中的 ax:# 添加注釋對于 ax.containers 中的 c:標簽 = [f'{(v.get_height()/1000):.1f}K' for v in c]ax.bar_label(c, 標簽=標簽, label_type='edge')ax.margins(y=0.2)plt.show()

                    I plotted a catplot in seaborn like this

                    import seaborn as sns
                    import pandas as pd
                    
                    data  = {'year': [2016, 2013, 2014, 2015, 2016, 2013, 2014, 2015, 2016, 2013, 2014, 2015, 2016, 2013, 2014, 2015, 2016, 2013, 2014, 2015], 'geo_name': ['Michigan', 'Michigan', 'Michigan', 'Michigan', 'Washtenaw County, MI', 'Washtenaw County, MI', 'Washtenaw County, MI', 'Washtenaw County, MI', 'Ann Arbor, MI', 'Ann Arbor, MI', 'Ann Arbor, MI', 'Ann Arbor, MI', 'Philadelphia, PA', 'Philadelphia, PA', 'Philadelphia, PA', 'Philadelphia, PA', 'Ann Arbor, MI Metro Area', 'Ann Arbor, MI Metro Area', 'Ann Arbor, MI Metro Area', 'Ann Arbor, MI Metro Area'], 'geo': ['04000US26', '04000US26', '04000US26', '04000US26', '05000US26161', '05000US26161', '05000US26161', '05000US26161', '16000US2603000', '16000US2603000', '16000US2603000', '16000US2603000', '16000US4260000', '16000US4260000', '16000US4260000', '16000US4260000', '31000US11460', '31000US11460', '31000US11460', '31000US11460'], 'income': [50803.0, 48411.0, 49087.0, 49576.0, 62484.0, 59055.0, 60805.0, 61003.0, 57697.0, 55003.0, 56835.0, 55990.0, 39770.0, 37192.0, 37460.0, 38253.0, 62484.0, 59055.0, 60805.0, 61003.0], 'income_moe': [162.0, 163.0, 192.0, 186.0, 984.0, 985.0, 958.0, 901.0, 2046.0, 1688.0, 1320.0, 1259.0, 567.0, 424.0, 430.0, 511.0, 984.0, 985.0, 958.0, 901.0]}
                    df = pd.DataFrame(data)
                    
                    g = sns.catplot(x='year', y='income', data=df, kind='bar', hue='geo_name', legend=True)
                    g.fig.set_size_inches(15,8)
                    g.fig.subplots_adjust(top=0.81,right=0.86)  
                    

                    I am getting an output like shown below

                    I want to add the values of each bar on its top in K representation. For example in 2013 the bar for Michigan is at 48411 so I want to add the value 48.4K on top of that bar. Likewise for all the bars.

                    解決方案

                    Updated as of matplotlib v3.4.2

                    • Use matplotlib.pyplot.bar_label
                    • See the matplotlib: Bar Label Demo page for additional formatting options.
                    • Tested with pandas v1.2.4, which is using matplotlib as the plot engine.
                    • Use the fmt parameter for simple formats, and labels parameter for customized string formatting.
                    • See Adding value labels on a matplotlib bar chart for other plotting options related to the new method.

                    For single plot only

                    g = sns.catplot(x='year', y='income', data=df, kind='bar', hue='geo_name', legend=True)
                    g.fig.set_size_inches(15, 8)
                    g.fig.subplots_adjust(top=0.81, right=0.86)
                    
                    # extract the matplotlib axes_subplot objects from the FacetGrid
                    ax = g.facet_axis(0, 0)
                    
                    # iterate through the axes containers
                    for c in ax.containers:
                        labels = [f'{(v.get_height() / 1000):.1f}K' for v in c]
                        ax.bar_label(c, labels=labels, label_type='edge')
                    

                    For single or multiple plots

                    g = sns.catplot(x='year', y='income', data=df, kind='bar', col='geo_name', col_wrap=3, legend=True)
                    g.fig.set_size_inches(15, 8)
                    g.fig.subplots_adjust(top=0.9)
                    
                    g.fig.suptitle('Bar Count with Annotations')
                    
                    # iterate through axes
                    for ax in g.axes.ravel():
                        
                        # add annotations
                        for c in ax.containers:
                            labels = [f'{(v.get_height() / 1000):.1f}K' for v in c]
                            ax.bar_label(c, labels=labels, label_type='edge')
                        ax.margins(y=0.2)
                    
                    plt.show()
                    

                    這篇關于Seaborn Catplot 在條形圖上設置值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                    【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)
                • <tfoot id='2o1dp'></tfoot>
                    <bdo id='2o1dp'></bdo><ul id='2o1dp'></ul>

                    1. <legend id='2o1dp'><style id='2o1dp'><dir id='2o1dp'><q id='2o1dp'></q></dir></style></legend>
                      1. <i id='2o1dp'><tr id='2o1dp'><dt id='2o1dp'><q id='2o1dp'><span id='2o1dp'><b id='2o1dp'><form id='2o1dp'><ins id='2o1dp'></ins><ul id='2o1dp'></ul><sub id='2o1dp'></sub></form><legend id='2o1dp'></legend><bdo id='2o1dp'><pre id='2o1dp'><center id='2o1dp'></center></pre></bdo></b><th id='2o1dp'></th></span></q></dt></tr></i><div class="5z7hfnj" id='2o1dp'><tfoot id='2o1dp'></tfoot><dl id='2o1dp'><fieldset id='2o1dp'></fieldset></dl></div>

                          <small id='2o1dp'></small><noframes id='2o1dp'>

                              <tbody id='2o1dp'></tbody>
                            主站蜘蛛池模板: 蚂蚁分类信息系统 - PHP同城分类信息系统 - MayiCMS | 电梯装饰-北京万达中意电梯装饰有限公司| 长沙广告公司_制作,长沙喷绘_发光字_招牌制作_长沙泓润广告官网 长城人品牌官网 | 不干胶标签-不干胶贴纸-不干胶标签定制-不干胶标签印刷厂-弗雷曼纸业(苏州)有限公司 | 深圳激光打标机_激光打标机_激光焊接机_激光切割机_同体激光打标机-深圳市创想激光科技有限公司 深圳快餐店设计-餐饮设计公司-餐饮空间品牌全案设计-深圳市勤蜂装饰工程 | 磷酸肌酸二钠盐,肌酐磷酰氯-沾化欣瑞康生物科技 | 废气处理_废气处理设备_工业废气处理_江苏龙泰环保设备制造有限公司 | 道达尔润滑油-食品级润滑油-道达尔导热油-合成导热油,深圳道达尔代理商合-深圳浩方正大官网 | 西安微信朋友圈广告投放_微信朋友圈推广_西安度娘网络科技有限公司 | 铝合金线槽_铝型材加工_空调挡水板厂家-江阴炜福金属制品有限公司 | 液压升降货梯_导轨式升降货梯厂家_升降货梯厂家-河南东圣升降设备有限公司 | 合肥地磅_合肥数控切割机_安徽地磅厂家_合肥世佳电工设备有限公司 | 闸阀_截止阀_止回阀「生产厂家」-上海卡比阀门有限公司 | 交通气象站_能见度检测仪_路面状况监测站- 天合环境科技 | 沟盖板_复合沟盖板厂_电力盖板_树脂雨水篦子-淄博拜斯特 | 石家庄救护车出租_重症转院_跨省跨境医疗转送_活动赛事医疗保障_康复出院_放弃治疗_腾康26年医疗护送转诊团队 | 立式_复合式_壁挂式智能化电伴热洗眼器-上海达傲洗眼器生产厂家 理化生实验室设备,吊装实验室设备,顶装实验室设备,实验室成套设备厂家,校园功能室设备,智慧书法教室方案 - 东莞市惠森教学设备有限公司 | 范秘书_懂你的范文小秘书 | 上海公司注册-代理记账-招投标审计-上海昆仑扇财税咨询有限公司 上海冠顶工业设备有限公司-隧道炉,烘箱,UV固化机,涂装设备,高温炉,工业机器人生产厂家 | 煤棒机_增碳剂颗粒机_活性炭颗粒机_木炭粉成型机-巩义市老城振华机械厂 | 汽车整车综合环境舱_军标砂尘_盐雾试验室试验箱-无锡苏南试验设备有限公司 | 电子万能试验机_液压拉力试验机_冲击疲劳试验机_材料试验机厂家-济南众标仪器设备有限公司 | 自动气象站_农业气象站_超声波气象站_防爆气象站-山东万象环境科技有限公司 | 苹果售后维修点查询,苹果iPhone授权售后维修服务中心 – 修果网 拼装地板,悬浮地板厂家,悬浮式拼装运动地板-石家庄博超地板科技有限公司 | 永嘉县奥阳陶瓷阀门有限公司| 防火阀、排烟防火阀、电动防火阀产品生产销售商-德州凯亿空调设备有限公司 | 中矗模型-深圳中矗模型设计有限公司 | 东莞ERP软件_广州云ERP_中山ERP_台湾工厂erp系统-广东顺景软件科技有限公司 | 并网柜,汇流箱,电控设备,中高低压开关柜,电气电力成套设备,PLC控制设备订制厂家,江苏昌伟业新能源科技有限公司 | 船用锚链|专业锚链生产厂家|安徽亚太锚链制造有限公司 | 淄博不锈钢,淄博不锈钢管,淄博不锈钢板-山东振远合金科技有限公司 | 磁棒电感生产厂家-电感器厂家-电感定制-贴片功率电感供应商-棒形电感生产厂家-苏州谷景电子有限公司 | 热工多功能信号校验仪-热电阻热电偶校验仿真仪-金湖虹润仪表 | 便携式表面粗糙度仪-彩屏硬度计-分体式粗糙度仪-北京凯达科仪科技有限公司 | 台式低速离心机-脱泡离心机-菌种摇床-常州市万丰仪器制造有限公司 | 山东齐鲁漆业有限公司【官网】-工业漆专业生产厂家 | 潍坊青州古城旅游景点攻略_青州酒店美食推荐-青州旅游网 | 可程式恒温恒湿试验箱|恒温恒湿箱|恒温恒湿试验箱|恒温恒湿老化试验箱|高低温试验箱价格报价-广东德瑞检测设备有限公司 | 免费B2B信息推广发布平台 - 推发网 | 外贸网站建设-外贸网站设计制作开发公司-外贸独立站建设【企术】 | 不锈钢拉手厂家|浴室门拉手厂家|江门市蓬江区金志翔五金制品有限公司 |