-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from jukent/template
add plotting template
- Loading branch information
Showing
1 changed file
with
246 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,246 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Plot Template\n", | ||
"\n", | ||
"Brief description of this type of plot.\n", | ||
"\n", | ||
"In geoscience, how is this plot used? Are there certain datasets more typically used with this type of plot?" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import xarray as xr\n", | ||
"import cartopy.crs as ccrs\n", | ||
"import cartopy.feature as cfeature\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"\n", | ||
"import geocat.datafiles as gdf" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Get Relevant Dataset" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Use Xarray and GeoCAT datafiles to pull up a sample relevant dataset\n", | ||
"ds = xr.open_dataset(gdf.get(\"\"), decode_times=False)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Simple Plot\n", | ||
"\n", | ||
"The simplest way to create any of this type of plot plot is simply to call up ``." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Base Case" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Generate figure (set its size (width, height) in inches)\n", | ||
"fig, ax = plt.subplots(figsize=(8, 6))\n", | ||
"\n", | ||
"# Plot the data in one line if possible.\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Simple Customizations\n", | ||
"\n", | ||
"In this example we demonstrate:\n", | ||
"- setting differnt kwargs with `a=1`.\n", | ||
"\n", | ||
"Check out [Matplotlib's `plot-type` documentation]() to see all the keyword argument customization options available to you." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Generate figure (set its size (width, height) in inches)\n", | ||
"fig, ax = plt.subplots(figsize=(8, 6))\n", | ||
"\n", | ||
"# Plot the data with relevant kwargs specified." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Plot with Cartopy\n", | ||
"\n", | ||
"If relevant, demonstrate how to plot data on a map. Talk about why this data should be on a map.\n", | ||
"\n", | ||
"In the below example, we demonstrate adding Cartopy Plate Carree axes, land features, and lat-lon gridlines.\n", | ||
"\n", | ||
"What is new in this plot? Don't do all of the Cartopy customization yet, just the bare minimum to make the map look as expected." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Generate figure (set its size (width, height) in inches) and axes using Cartopy projection\n", | ||
"fig = plt.figure(figsize=(8, 6))\n", | ||
"\n", | ||
"# Generate axes using Cartopy\n", | ||
"ax = plt.axes(projection=ccrs.PlateCarree())\n", | ||
"\n", | ||
"# Turn on continent shading\n", | ||
"ax.add_feature(cfeature.LAND,\n", | ||
" zorder=0)\n", | ||
"\n", | ||
"# Plot the data on the map\n", | ||
"\n", | ||
"plt.title(\"\");" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Cartopy Customization\n", | ||
"\n", | ||
"You can change the way your Cartopy plot looks with the inclusion of `edgecolor` and `facecolor` specifications. Light gray tends to look nice." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Generate figure (set its size (width, height) in inches) and axes using Cartopy projection\n", | ||
"fig = plt.figure(figsize=(8, 6))\n", | ||
"\n", | ||
"# Generate axes using Cartopy\n", | ||
"ax = plt.axes(projection=ccrs.PlateCarree())\n", | ||
"\n", | ||
"# Turn on continent shading\n", | ||
"ax.add_feature(cfeature.LAND,\n", | ||
" edgecolor='lightgray',\n", | ||
" facecolor='lightgray',\n", | ||
" zorder=0)\n", | ||
"\n", | ||
"# Plot the data on the map\n", | ||
"\n", | ||
"plt.title(\"\");" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Another layer of information on the plot\n", | ||
"\n", | ||
"If your plot can be customized to display more information, now is the time to demonstrate that. Go through default then customization steps for each new thing (such as colorbars) that you add." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Finishing Touches" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Grid Lines\n", | ||
"\n", | ||
"Does this plot benefit from gridlines? Add them now and talk about it." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### Titles and Labels\n", | ||
"\n", | ||
"All plots should have an informative title. In this final step we add a title to our plot and turn off the redundant top and right gridlabels." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## References\n", | ||
"\n", | ||
"Want to go deeper in your understanding of the topic or the available keyword arguments, check out these resources:\n", | ||
"\n", | ||
" - [Link to Documentation]()\n", | ||
" - [Another link]()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "geocat-applications", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.10.10" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |