Skip to content

Commit

Permalink
Port categorical plot docstrings to notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaskom committed Jun 15, 2022
1 parent 057cdd8 commit 9d8ce6a
Show file tree
Hide file tree
Showing 29 changed files with 1,085 additions and 644 deletions.
2 changes: 1 addition & 1 deletion doc/docstrings/FacetGrid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion doc/docstrings/JointGrid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion doc/docstrings/PairGrid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion doc/docstrings/axes_style.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.5"
"version": "3.9.9"
}
},
"nbformat": 4,
Expand Down
125 changes: 125 additions & 0 deletions doc/docstrings/barplot.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "6a6d582b-08c2-4fed-be56-afa1b986943a",
"metadata": {
"tags": [
"hide"
]
},
"outputs": [],
"source": [
"import seaborn as sns\n",
"sns.set_theme(style=\"whitegrid\")"
]
},
{
"cell_type": "markdown",
"id": "a7ef20b6-3bd8-4992-a270-4c3ecc86a0fa",
"metadata": {},
"source": [
"Group by a categorical varaible and plot aggregated values, with confidence intervals:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0f5c3ece-6295-4933-8a87-e80cd604c089",
"metadata": {},
"outputs": [],
"source": [
"df = sns.load_dataset(\"penguins\")\n",
"sns.barplot(data=df, x=\"island\", y=\"body_mass_g\")"
]
},
{
"cell_type": "markdown",
"id": "38f7c39e-485d-4b50-ac21-f1b402f26aa4",
"metadata": {},
"source": [
"Add a second layer of grouping:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ac1a28d1-b3bd-4158-86d0-3defc12f8566",
"metadata": {},
"outputs": [],
"source": [
"sns.barplot(data=df, x=\"island\", y=\"body_mass_g\", hue=\"sex\")"
]
},
{
"cell_type": "markdown",
"id": "7f8fa070-a8f4-41fb-be74-c489acbdbcbe",
"metadata": {},
"source": [
"Use the error bars to show the standard deviation rather than a confidence interval:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10445b78-a74a-4f14-a28b-a9164e592ae4",
"metadata": {},
"outputs": [],
"source": [
"sns.barplot(data=df, x=\"island\", y=\"body_mass_g\", ci=\"sd\")"
]
},
{
"cell_type": "markdown",
"id": "7f579f70-39a2-4d0c-baa2-9adae11ce2ce",
"metadata": {},
"source": [
"Customize the appearance of the plot:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d6f9ac1c-a77d-4ee3-bc5e-fec2071b33df",
"metadata": {},
"outputs": [],
"source": [
"sns.barplot(\n",
" data=df, x=\"body_mass_g\", y=\"island\",\n",
" ci=\"sd\", capsize=.4, errcolor=\".5\",\n",
" linewidth=3, edgecolor=\".5\", facecolor=(0, 0, 0, 0),\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "faedd6f9-a123-4927-9eff-a2046edf5c72",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "seaborn-py39-latest",
"language": "python",
"name": "seaborn-py39-latest"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
130 changes: 130 additions & 0 deletions doc/docstrings/boxenplot.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "882d215b-88d8-4b5e-ae7a-0e3f6bb53bad",
"metadata": {
"tags": [
"hide"
]
},
"outputs": [],
"source": [
"import seaborn as sns\n",
"sns.set_theme(style=\"whitegrid\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6809326c-14a9-4314-994d-b4e8e7414172",
"metadata": {},
"outputs": [],
"source": [
"df = sns.load_dataset(\"diamonds\")"
]
},
{
"cell_type": "markdown",
"id": "9ccbc2d5-5a44-4e80-8b07-e12629729f4a",
"metadata": {},
"source": [
"Draw a single horizontal plot, assigning the data directly to the coordinate variable:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "391e1162-b438-4486-9a08-60686ee8e96a",
"metadata": {},
"outputs": [],
"source": [
"sns.boxenplot(x=df[\"price\"])"
]
},
{
"cell_type": "markdown",
"id": "a3b0e9b8-1673-494c-a27a-aa9c60457ba1",
"metadata": {},
"source": [
"Group by a categorical variable, referencing columns in a datafame"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e30fec18-f127-40a3-bfaf-f71324dd60ec",
"metadata": {},
"outputs": [],
"source": [
"sns.boxenplot(data=df, x=\"price\", y=\"clarity\")"
]
},
{
"cell_type": "markdown",
"id": "4f01a821-74d1-452d-a1f7-cf5b806169e8",
"metadata": {},
"source": [
"Use a different scaling rule to control the width of each box:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d0c1aa43-5e8a-486c-bd6d-3c29d6d23138",
"metadata": {},
"outputs": [],
"source": [
"sns.boxenplot(data=df, x=\"carat\", y=\"cut\", scale=\"linear\")"
]
},
{
"cell_type": "markdown",
"id": "fd5d197c-8cbb-4be3-a14d-76447f06d3f1",
"metadata": {},
"source": [
"Use a different method to determine the number of boxes:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1aead6a3-6f12-47d3-b472-a39c61867963",
"metadata": {},
"outputs": [],
"source": [
"sns.boxenplot(data=df, x=\"carat\", y=\"cut\", k_depth=\"trustworthy\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "719fd61f-9795-47d6-96bd-4929d8647038",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "seaborn-py39-latest",
"language": "python",
"name": "seaborn-py39-latest"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 9d8ce6a

Please sign in to comment.