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

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

    <tfoot id='nWQGW'></tfoot>

    1. <i id='nWQGW'><tr id='nWQGW'><dt id='nWQGW'><q id='nWQGW'><span id='nWQGW'><b id='nWQGW'><form id='nWQGW'><ins id='nWQGW'></ins><ul id='nWQGW'></ul><sub id='nWQGW'></sub></form><legend id='nWQGW'></legend><bdo id='nWQGW'><pre id='nWQGW'><center id='nWQGW'></center></pre></bdo></b><th id='nWQGW'></th></span></q></dt></tr></i><div id='nWQGW'><tfoot id='nWQGW'></tfoot><dl id='nWQGW'><fieldset id='nWQGW'></fieldset></dl></div>
        <bdo id='nWQGW'></bdo><ul id='nWQGW'></ul>

      如何在海运直方图上添加标准普通pdf

      How to add a standard normal pdf over a seaborn histogram(如何在海运直方图上添加标准普通pdf)
      <i id='grNVi'><tr id='grNVi'><dt id='grNVi'><q id='grNVi'><span id='grNVi'><b id='grNVi'><form id='grNVi'><ins id='grNVi'></ins><ul id='grNVi'></ul><sub id='grNVi'></sub></form><legend id='grNVi'></legend><bdo id='grNVi'><pre id='grNVi'><center id='grNVi'></center></pre></bdo></b><th id='grNVi'></th></span></q></dt></tr></i><div id='grNVi'><tfoot id='grNVi'></tfoot><dl id='grNVi'><fieldset id='grNVi'></fieldset></dl></div>

          <tbody id='grNVi'></tbody>
        • <tfoot id='grNVi'></tfoot>

        • <small id='grNVi'></small><noframes id='grNVi'>

            • <bdo id='grNVi'></bdo><ul id='grNVi'></ul>
              <legend id='grNVi'><style id='grNVi'><dir id='grNVi'><q id='grNVi'></q></dir></style></legend>

              1. 本文介绍了如何在海运直方图上添加标准普通pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想在用seaborn构建的直方图上添加标准的普通pdf曲线。

                import numpy as np
                import seaborn as sns 
                x = np.random.standard_normal(1000)
                sns.distplot(x, kde = False)
                

                如有任何帮助,我们将不胜感激!

                推荐答案

                • scipy.stats.norm使用
                  可以轻松访问正态分布的pdf 已知参数;默认情况下,它对应于标准法线,mu=0sigma=1
                  • 无论数据平均值位于何处(例如mu=0mu=10),此答案都适用。
                • 测试于python 3.8.11matplotlib 3.4.2seaborn 0.11.2
                • 本问答适用于轴级图;图级图请参见How to draw a normal curve on seaborn displot

                导入和数据

                import numpy as np                                                              
                import seaborn as sns                                                           
                from scipy import stats                                                         
                import matplotlib.pyplot as plt  
                
                # data
                np.random.seed(365)
                x = np.random.standard_normal(1000)    
                

                seaborn.histplot

                ax = sns.histplot(x, kde=False, stat='density', label='samples')
                
                # calculate the pdf
                x0, x1 = ax.get_xlim()  # extract the endpoints for the x-axis
                x_pdf = np.linspace(x0, x1, 100)
                y_pdf = scipy.stats.norm.pdf(x_pdf)
                
                ax.plot(x_pdf, y_pdf, 'r', lw=2, label='pdf')                                                   
                ax.legend()
                

                seaborn.distplot-已弃用

                • 为使其与您的采样数据正确对应,直方图应
                  显示密度而不计数,因此在seaborn.distplot调用中使用norm_hist=True
                ax = sns.distplot(x, kde = False, norm_hist=True, hist_kws={'ec': 'k'}, label='samples')
                
                # calculate the pdf
                x0, x1 = ax.get_xlim()  # extract the endpoints for the x-axis
                x_pdf = np.linspace(x0, x1, 100)
                y_pdf = scipy.stats.norm.pdf(x_pdf)
                
                ax.plot(x_pdf, y_pdf, 'r', lw=2, label='pdf')                                                     
                ax.legend()
                

                这篇关于如何在海运直方图上添加标准普通pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                  <legend id='EIeP5'><style id='EIeP5'><dir id='EIeP5'><q id='EIeP5'></q></dir></style></legend>

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

                  • <tfoot id='EIeP5'></tfoot>
                    • <bdo id='EIeP5'></bdo><ul id='EIeP5'></ul>
                      <i id='EIeP5'><tr id='EIeP5'><dt id='EIeP5'><q id='EIeP5'><span id='EIeP5'><b id='EIeP5'><form id='EIeP5'><ins id='EIeP5'></ins><ul id='EIeP5'></ul><sub id='EIeP5'></sub></form><legend id='EIeP5'></legend><bdo id='EIeP5'><pre id='EIeP5'><center id='EIeP5'></center></pre></bdo></b><th id='EIeP5'></th></span></q></dt></tr></i><div id='EIeP5'><tfoot id='EIeP5'></tfoot><dl id='EIeP5'><fieldset id='EIeP5'></fieldset></dl></div>
                          <tbody id='EIeP5'></tbody>