-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
296 additions
and
3 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
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,103 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# `add_right_hand_axis`\n", | ||
"\n", | ||
"This notebook is a simple example of the GeoCAT-viz function <a href=\"../user_api/generated/geocat.viz.util.add_right_hand_axis.html#geocat-viz.util.add_right_hand_axis\">add_right_hand_axis</a>." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import xarray as xr\n", | ||
"import matplotlib as mpl\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"from cartopy.mpl.ticker import LatitudeFormatter\n", | ||
"\n", | ||
"import geocat.datafiles as gdf\n", | ||
"import geocat.viz as gv" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Read in Data\n", | ||
"\n", | ||
"# Open a netCDF data file using xarray default engine and load the data into an xarray\n", | ||
"ds = xr.open_dataset(gdf.get('netcdf_files/atmos.nc'), decode_times=False)\n", | ||
"\n", | ||
"# Select zonal wind\n", | ||
"u = ds.U.isel(time=0)\n", | ||
"\n", | ||
"# Get zonal mean\n", | ||
"u_av = u.mean(dim='lon')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Plot:\n", | ||
"\n", | ||
"# Generate figure (set its size (width, height) in inches)\n", | ||
"plt.figure(figsize=(9, 10))\n", | ||
"ax1 = plt.gca()\n", | ||
"\n", | ||
"# Plot contour lines\n", | ||
"contours = u_av.plot.contour(ax=ax1,\n", | ||
" levels=13,\n", | ||
" vmin=-8,\n", | ||
" vmax=40,\n", | ||
" colors='black',\n", | ||
" linewidths=0.5,\n", | ||
" linestyles='solid',\n", | ||
" add_labels=False)\n", | ||
"\n", | ||
"# Add second axis to plot heights (heights chosen arbitrarily)\n", | ||
"gv.add_right_hand_axis(ax1,\n", | ||
" label=\"Right Hand Axis\",\n", | ||
" ylim=(0, 13),\n", | ||
" yticks=np.array([4, 8]),\n", | ||
" ticklabelsize=15,\n", | ||
" axislabelsize=21)\n", | ||
"\n", | ||
"plt.show();" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "geocat_viz_build", | ||
"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.0" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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,70 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# `set_tick_direction_spine_visibility`\n", | ||
"\n", | ||
"This notebook is a simple example of the GeoCAT-viz function <a href=\"../user_api/generated/geocat.viz.util.set_tick_direction_spine_visibility.html#geocat-viz.util.set_tick_direction_spine_visibility\">set_tick_direction_spine_visibility</a>." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Import packages:\n", | ||
"\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"import geocat.viz as gv" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Plot:\n", | ||
"\n", | ||
"# Create figure and axis\n", | ||
"fig, ax = plt.subplots(figsize=(6, 6))\n", | ||
"\n", | ||
"# Use geocat.viz.util convenience function to set spines visibility\n", | ||
"gv.set_tick_direction_spine_visibility(ax,\n", | ||
" tick_direction='in',\n", | ||
" top_spine_visible=False,\n", | ||
" right_spine_visible=False)\n", | ||
"\n", | ||
"# Display Plot\n", | ||
"plt.tight_layout()\n", | ||
"plt.show();" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "geocat_viz_build", | ||
"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.0" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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