

.. _sphx_glr_gallery_statistics:

.. _statistics_examples:

Statistics
==========



.. raw:: html

    <div class="sphx-glr-thumbnails">

.. thumbnail-parent-div-open

.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates how to use the various keyword arguments to fully customize box plots. The first figure demonstrates how to remove and add individual components (note that the mean is the only value not shown by default). The second figure demonstrates how the styles of the artists can be customized. It also demonstrates how to set the limit of the whiskers to specific percentiles (lower right Axes)">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_boxplot_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_boxplot.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Artist customization in box plots</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="To color each box of a box plot individually:">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_boxplot_color_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_boxplot_color.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Box plots with custom fill colors</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Visualizing boxplots with matplotlib.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_boxplot_demo_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_boxplot_demo.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Boxplots</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Note that although violin plots are closely related to Tukey&#x27;s (1977) box plots, they add useful information such as the distribution of the sample data (density trace).">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_boxplot_vs_violin_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_boxplot_vs_violin.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Box plot vs. violin plot comparison</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Drawing a boxplot for a given data set, consists of two main operations, that can also be used separately:">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_bxp_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_bxp.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Separate calculation and plotting of boxplots</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example shows how to plot a confidence ellipse of a two-dimensional dataset, using its pearson correlation coefficient.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_confidence_ellipse_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_confidence_ellipse.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Plot a confidence ellipse of a two-dimensional dataset</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates how to fully customize violin plots. The first plot shows the default style by providing only the data. The second plot first limits what Matplotlib draws with additional keyword arguments. Then a simplified representation of a box plot is drawn on top. Lastly, the styles of the artists of the violins are modified.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_customized_violin_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_customized_violin.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Violin plot customization</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This exhibits the most basic use of the error bar method. In this case, constant values are provided for the error in both the x- and y-directions.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_errorbar_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_errorbar.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Errorbar function</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Errors can be specified as a constant value (as shown in /gallery/statistics/errorbar). However, this example demonstrates how they vary by specifying arrays of error values.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_errorbar_features_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_errorbar_features.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Different ways of specifying error bars</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In matplotlib, errors bars can have &quot;limits&quot;. Applying limits to the error bars essentially makes the error unidirectional. Because of that, upper and lower limits can be applied in both the y- and x-directions via the uplims, lolims, xuplims, and xlolims parameters, respectively. These parameters can be scalar or boolean arrays.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_errorbar_limits_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_errorbar_limits.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Including upper and lower limits in error bars</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="In this example, we snazz up a pretty standard error bar plot by adding a rectangle patch defined by the limits of the bars in both the x- and y- directions. To do this, we have to write our own custom function called make_error_boxes. Close inspection of this function will reveal the preferred pattern in writing functions for matplotlib:">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_errorbars_and_boxes_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_errorbars_and_boxes.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Create boxes from error bars using PatchCollection</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="hexbin is a 2D histogram plot, in which the bins are hexagons and the color represents the number of data points within each bin.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_hexbin_demo_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_hexbin_demo.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Hexagonal binned plot</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="How to plot histograms with Matplotlib.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_hist_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_hist.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Histograms</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="How to plot a bihistogram with Matplotlib.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_histogram_bihistogram_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_histogram_bihistogram.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Bihistogram</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example shows how to plot the empirical cumulative distribution function (ECDF) of a sample. We also show the theoretical CDF.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_histogram_cumulative_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_histogram_cumulative.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Cumulative distributions</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip=" Histogram with step curve that has a color fill.  Histogram with step curve with no fill.  Histogram with custom and unequal bin widths.  Two histograms with stacked bars.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_histogram_histtypes_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_histogram_histtypes.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Demo of the histogram function's different histtype settings</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Plot histogram with multiple sample sets and demonstrate:">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_histogram_multihist_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_histogram_multihist.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">The histogram (hist) function with multiple data sets</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="The Axes.hist method can flexibly create histograms in a few different ways, which is flexible and helpful, but can also lead to confusion.  In particular, you can:">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_histogram_normalization_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_histogram_normalization.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Histogram bins, density, and weight</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example plots horizontal histograms of different samples along a categorical x-axis. Additionally, the histograms are plotted to be symmetrical about their x-position, thus making them very similar to violin plots.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_multiple_histograms_side_by_side_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_multiple_histograms_side_by_side.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Multiple histograms side by side</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="This example demonstrates how to efficiently visualize large numbers of time series in a way that could potentially reveal hidden substructure and patterns that are not immediately obvious, and display them in a visually appealing way.">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_time_series_histogram_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_time_series_histogram.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Time Series Histogram</div>
    </div>


.. raw:: html

    <div class="sphx-glr-thumbcontainer" tooltip="Violin plots are similar to histograms and box plots in that they show an abstract representation of the probability distribution of the sample. Rather than showing counts of data points that fall into bins or order statistics, violin plots use kernel density estimation (KDE) to compute an empirical distribution of the sample. That computation is controlled by several parameters. This example demonstrates how to modify the number of points at which the KDE is evaluated (``points``) and how to modify the bandwidth of the KDE (``bw_method``).">

.. only:: html

  .. image:: /gallery/statistics/images/thumb/sphx_glr_violinplot_thumb.png
    :alt:

  :ref:`sphx_glr_gallery_statistics_violinplot.py`

.. raw:: html

      <div class="sphx-glr-thumbnail-title">Violin plot basics</div>
    </div>


.. thumbnail-parent-div-close

.. raw:: html

    </div>


.. toctree::
   :hidden:

   /gallery/statistics/boxplot
   /gallery/statistics/boxplot_color
   /gallery/statistics/boxplot_demo
   /gallery/statistics/boxplot_vs_violin
   /gallery/statistics/bxp
   /gallery/statistics/confidence_ellipse
   /gallery/statistics/customized_violin
   /gallery/statistics/errorbar
   /gallery/statistics/errorbar_features
   /gallery/statistics/errorbar_limits
   /gallery/statistics/errorbars_and_boxes
   /gallery/statistics/hexbin_demo
   /gallery/statistics/hist
   /gallery/statistics/histogram_bihistogram
   /gallery/statistics/histogram_cumulative
   /gallery/statistics/histogram_histtypes
   /gallery/statistics/histogram_multihist
   /gallery/statistics/histogram_normalization
   /gallery/statistics/multiple_histograms_side_by_side
   /gallery/statistics/time_series_histogram
   /gallery/statistics/violinplot

