Skip to content

Commit

Permalink
Add new errorbar options to bar/pointplot (#2866)
Browse files Browse the repository at this point in the history
* Get errorbar= working in barplot

* Add new errorbar options to bar/pointplot

* Update release notes and fix pointplot tests

* Add  examples to point/barplot API docs

* Fill out error bar user guide chapter

* Add errorbar example to categorical tutorial (and update call style)
  • Loading branch information
mwaskom authored Jun 18, 2022
1 parent 1191b61 commit ecba2dc
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 232 deletions.
4 changes: 2 additions & 2 deletions doc/docstrings/barplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"metadata": {},
"outputs": [],
"source": [
"sns.barplot(data=df, x=\"island\", y=\"body_mass_g\", ci=\"sd\")"
"sns.barplot(data=df, x=\"island\", y=\"body_mass_g\", errorbar=\"sd\")"
]
},
{
Expand All @@ -87,7 +87,7 @@
"source": [
"sns.barplot(\n",
" data=df, x=\"body_mass_g\", y=\"island\",\n",
" ci=\"sd\", capsize=.4, errcolor=\".5\",\n",
" errorbar=(\"pi\", 50), capsize=.4, errcolor=\".5\",\n",
" linewidth=3, edgecolor=\".5\", facecolor=(0, 0, 0, 0),\n",
")"
]
Expand Down
4 changes: 2 additions & 2 deletions doc/docstrings/pointplot.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"metadata": {},
"outputs": [],
"source": [
"sns.pointplot(data=df, x=\"island\", y=\"body_mass_g\", ci=\"sd\")"
"sns.pointplot(data=df, x=\"island\", y=\"body_mass_g\", errorbar=\"sd\")"
]
},
{
Expand All @@ -105,7 +105,7 @@
"source": [
"sns.pointplot(\n",
" data=df, x=\"body_mass_g\", y=\"island\",\n",
" ci=\"sd\", capsize=.4, join=False, color=\".5\",\n",
" errorbar=(\"pi\", 100), capsize=.4, join=False, color=\".5\",\n",
")"
]
},
Expand Down
19 changes: 16 additions & 3 deletions doc/releases/v0.12.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This release begins the process of modernizing the :ref:`categorical plots <cate

- |Enhancement| It is now possible to assign `hue` when using only one coordinate variable (i.e. only `x` or `y`).

- |Enhancement| It is now possible to disable the legend.

The updates also harmonize behavior with functions that have been more recently introduced. This should be relatively non-disruptive, although a few defaults will change:

- |Defaults| The functions now hook into matplotlib's unit system for plotting categorical data. (Seaborn's categorical functions actually predate support for categorical data in matplotlib.) This should mostly be transparent to the user, but it may resolve a few edge cases. For example, matplotlib interactivity should work better (e.g., for showing the data value under the cursor).
Expand All @@ -42,14 +44,23 @@ Similar enhancements / updates should be expected to roll out to other categoric

- |Fix| In :func:`swarmplot`, the order of the points in each swarm now matches the order in the original dataset; previously they were sorted. This affects only the underlying data stored in the matplotlib artist, not the visual representation (:pr:`2443`).

More flexible errorbars
~~~~~~~~~~~~~~~~~~~~~~~

|API| |Feature|

Increased the flexibility of what can be shown by the internally-calculated errorbars for :func:`lineplot`, :func:`barplot`, and :func:`pointplot`.

With the new `errorbar` parameter, it is now possible to select bootstrap confidence intervals, percentile / predictive intervals, or intervals formed by scaled standard deviations or standard errors. The parameter also accepts an arbitrary function that maps from a vector to an interval. There is a new :doc:`user guide chapter <errorbar_tutorial>` demonstrating these options and explaining when you might want to use each one.

As a consequence of this change, the `ci` parameter has been deprecated. Note that :func:`regplot` does not yet have access to this feature, but it likely will be added there in a future release (:pr:`2407`, :pr:`2866`).

Other updates
~~~~~~~~~~~~~

- |Feature| Increased the flexibility of what can be shown by the internally-calculated errorbars for :func:`lineplot`. With the new `errorbar` parameter, it is now possible to select bootstrap confidence intervals, percentile / predictive intervals, or intervals formed by scaled standard deviations or standard errors. As a consequence of this change, the `ci` parameter has been deprecated. Similar changes will be made to other functions that aggregate data points in future releases. (:pr:`2407`).

- |Feature| It is now possible to aggregate / sort a :func:`lineplot` along the y axis using `orient="y"` (:pr:`2854`).

- |Enhancement| Example datasets are now stored in an OS-specific cache location (as determined by `appdirs`) rather than in the user's home directory. Users should feel free to remove `~/seaborn-data` if desired (:pr:`2773`).
- |Feature| It is now possible to specify `estimator` as a string in :func:`barplot` and :func:`pointplot`, in addition to a callable (:pr:`2866`).

- |Enhancement| Added a `width` parameter to :func:`barplot` (:pr:`2860`).

Expand Down Expand Up @@ -87,6 +98,8 @@ Other updates

- |Dependencies| Following `NEP29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_, dropped support for Python 3.6 and bumped the minimally-supported versions of the library dependencies.

- |Dependencies| Example datasets are now stored in an OS-specific cache location (as determined by `appdirs`) rather than in the user's home directory. Users should feel free to remove `~/seaborn-data` if desired (:pr:`2773`).

- |Dependencies| The unit test suite is no longer part of the source or wheel distribution. Seaborn has never had a runtime API for exercising the tests, so this should not have workflow implications (:pr:`2833`).

- |API| Removed the previously-deprecated `factorplot` along with several previously-deprecated utility functions (`iqr`, `percentiles`, `pmf_hist`, and `sort_df`).
Loading

0 comments on commit ecba2dc

Please sign in to comment.