Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature reference gallery #999

Merged
merged 4 commits into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/reference/pandas/kde.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
2 changes: 1 addition & 1 deletion examples/reference/pandas/line.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
76 changes: 76 additions & 0 deletions examples/reference/xarray/bar.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "5d0ed0f8-ce26-4c54-9161-d34ca73ae716",
"metadata": {},
"outputs": [],
"source": [
"import hvplot.xarray # noqa\n",
"import xarray as xr"
]
},
{
"cell_type": "markdown",
"id": "e3f7e297-9576-4c36-9a9f-a4200ccf2d36",
"metadata": {},
"source": [
"## Introduction\n",
"\n",
"A `bar` plot represents **categorical data** with rectangular bars with heights proportional to the **numerical values** that they represent.\n",
"The x-axis represents the categories and the y axis represents the numerical value scale.\n",
"The bars are of equal width which allows for instant comparison of data."
]
},
{
"cell_type": "markdown",
"id": "af429bbb-9a65-4b5d-b447-ce50b35dfedc",
"metadata": {},
"source": [
"## Data\n",
"\n",
"Let's load some data."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8db8fff7-b85f-49ea-b281-4a4d86e0f3ee",
"metadata": {},
"outputs": [],
"source": [
"ds = xr.tutorial.open_dataset('air_temperature').load()\n",
"air = ds.air\n",
"air1d = air.sel(lon=285.,lat=40.).groupby('time.month').mean()\n",
"air1d"
]
},
{
"cell_type": "markdown",
"id": "629c5172-9cba-4f5f-bf3b-67e0a390385b",
"metadata": {},
"source": [
"## Basic Bar Plots"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dfd1afa2-e310-4630-bd30-96e390078caf",
"metadata": {},
"outputs": [],
"source": [
"air1d.hvplot.bar(y='air', height=500, title=\"Air Temperature by Month\")"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
66 changes: 66 additions & 0 deletions examples/reference/xarray/hist.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import hvplot.xarray # noqa\n",
"import xarray as xr"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`hist` is often a good way to start looking at data to get a sense of the distribution. Similar methods include [`kde`](kde.ipny) (also available as `density`)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds = xr.tutorial.open_dataset('air_temperature').load()\n",
"air = ds.air\n",
"air1d = air.sel(lon=285.,lat=40.)\n",
"air1d"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"air1d.hvplot.hist()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Customize the plot by changing the title and bar color."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"air1d.hvplot.hist(title=\"Air Temperature over time at lat=40,lon285\", color='gray')"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
53 changes: 53 additions & 0 deletions examples/reference/xarray/kde.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "2ccf9fd5-9d10-4522-961d-7e8d236213b2",
"metadata": {},
"outputs": [],
"source": [
"import hvplot.xarray # noqa\n",
"import xarray as xr"
]
},
{
"cell_type": "markdown",
"id": "f7ed6c65-2280-4741-b89b-721110628547",
"metadata": {},
"source": [
"Kernel density estimate (`kde`) provides a mechanism for showing the distribution and spread of the data. In `hvplot` the method is exposed both as `kde` and `density`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e8680d48-02b1-4480-96e3-d0fd7807a804",
"metadata": {},
"outputs": [],
"source": [
"ds = xr.tutorial.open_dataset('air_temperature').load()\n",
"air = ds.air\n",
"air1d = air.sel(lat=[25, 50, 75])"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f33d3355-deaa-4bdf-befa-af20d2e46d7a",
"metadata": {},
"outputs": [],
"source": [
"air1d.hvplot.kde('air', by='lat', alpha=0.5)"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
66 changes: 66 additions & 0 deletions examples/reference/xarray/line.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import hvplot.xarray # noqa\n",
"import xarray as xr"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`line` is useful when data is continuous and has a continuous axis."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ds = xr.tutorial.open_dataset('air_temperature').load()\n",
"air = ds.air\n",
"air1d = air.sel(lon=285.,lat=40.)\n",
"air1d"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"air1d.hvplot.line()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Customize the plot by changing the title and line color."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"air1d.hvplot.line(title=\"Air Temperature over time at lat=40,lon285\",line_color='gray')"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
53 changes: 53 additions & 0 deletions examples/reference/xarray/violin.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "2ccf9fd5-9d10-4522-961d-7e8d236213b2",
"metadata": {},
"outputs": [],
"source": [
"import hvplot.xarray # noqa\n",
"import xarray as xr"
]
},
{
"cell_type": "markdown",
"id": "f7ed6c65-2280-4741-b89b-721110628547",
"metadata": {},
"source": [
"`violin` plots are similar to box plots, but provide a better sense of the distribution of data. Note that `violin` plots depend on the `scipy` library."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e0f6ecc7-0f6a-4590-9c98-da10a674b9b0",
"metadata": {},
"outputs": [],
"source": [
"ds = xr.tutorial.open_dataset('air_temperature').load()\n",
"air = ds.air\n",
"air"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2a137994-0a9d-4a75-8192-1e4bb4ead6c5",
"metadata": {},
"outputs": [],
"source": [
"air.hvplot.violin(y='air', by='lat', color='lat', cmap='Category20', title=\"Air Temperature vs. latitude\")"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}