-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port categorical plot docstrings to notebooks
- Loading branch information
Showing
29 changed files
with
1,085 additions
and
644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.