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

Add additional usage examples and update a thumbnail #181

Merged
merged 4 commits into from
Nov 27, 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
Binary file modified docs/_static/thumbnails/plot_contour_labels.png
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.
Binary file added docs/_static/thumbnails/set_titles_and_labels.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Here are some examples of how to use geocat-viz.
examples/add_lat_lon_gridlines.ipynb
examples/add_lat_lon_ticklabels.ipynb
examples/set_tick_direction_spine_visibility.ipynb
examples/set_titles_and_labels.ipynb
examples/set_axes_limits_and_ticks.ipynb
examples/add_right_hand_axis.ipynb
examples/add_major_minor_ticks.ipynb
examples/find_local_extrema.ipynb
Expand Down
87 changes: 87 additions & 0 deletions docs/examples/set_axes_limits_and_ticks.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# `set_axes_limits_and_ticks`\n",
"\n",
"This notebook is a simple example of the GeoCAT-viz function <a href=\"../user_api/generated/geocat.viz.util.set_axes_limits_and_ticks.html#geocat-viz.util.set_axes_limits_and_ticks\">set_axes_limits_and_ticks</a>."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Import packages:\n",
"\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import geocat.viz as gv"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Generate example data:\n",
"\n",
"npts = 500\n",
"\n",
"x = 500 + 0.9 * np.arange(0, npts) * np.cos(np.pi / 100 * np.arange(0, npts))\n",
"y = 500 + 0.9 * np.arange(0, npts) * np.sin(np.pi / 100 * np.arange(0, npts))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create plot\n",
"\n",
"# Create a figure\n",
"fig, ax = plt.subplots()\n",
"\n",
"# Plot the example data\n",
"ax.plot(x, y)\n",
"\n",
"# Use geocat.viz.util convenience function to set axes limits and tick labels\n",
"gv.set_axes_limits_and_ticks(ax,\n",
" xlim=(0, 900),\n",
" ylim=(100, 1000),\n",
" xticks=range(0, 901, 100),\n",
" yticks=range(100, 1001, 100))\n",
"\n",
"# Show the plot\n",
"plt.show();"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
88 changes: 88 additions & 0 deletions docs/examples/set_titles_and_labels.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# `set_titles_and_labels`\n",
"\n",
"This notebook is a simple example of the GeoCAT-viz function <a href=\"../user_api/generated/geocat.viz.util.set_titles_and_labels.html#geocat-viz.util.set_titles_and_labels\">set_titles_and_labels</a>."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Import packages:\n",
"\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import geocat.viz as gv"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Generate example data:\n",
"\n",
"npts = 500\n",
"\n",
"x = 500 + 0.9 * np.arange(0, npts) * np.cos(np.pi / 100 * np.arange(0, npts))\n",
"y = 500 + 0.9 * np.arange(0, npts) * np.sin(np.pi / 100 * np.arange(0, npts))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Create plot\n",
"\n",
"# Create a figure\n",
"fig, ax = plt.subplots()\n",
"\n",
"# Plot the example data\n",
"ax.plot(x, y)\n",
"\n",
"# Use geocat.viz.util convenience function to set titles and labels\n",
"gv.set_titles_and_labels(ax,\n",
" maintitle=\"Title\",\n",
" maintitlefontsize=24,\n",
" xlabel=\"x\",\n",
" ylabel=\"y\",\n",
" labelfontsize=16)\n",
"\n",
"# Show the plot\n",
"plt.show();"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
8 changes: 8 additions & 0 deletions docs/gallery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@
- title: 'plot_extrema_labels'
path: examples/plot_extrema_labels.ipynb
thumbnail: _static/thumbnails/plot_extrema_labels.png

- title: 'set_titles_and_labels'
path: examples/set_titles_and_labels.ipynb
thumbnail: _static/thumbnails/set_titles_and_labels.png

- title: 'set_axes_limits_and_ticks'
path: examples/set_axes_limits_and_ticks.ipynb
thumbnail: _static/thumbnails/set_axes_limits_and_ticks.png
5 changes: 3 additions & 2 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ Release Notes

v2023.11.0 (Unreleased)
-----------------------
[Plain text summary here]


Documentation
^^^^^^^^^^^^^
* Invert y-axis in add_height_from_pressure_axis example by `Katelyn FitzGerald`_ in (:pr:`173`)
* Invert y-axis in ``add_height_from_pressure_axis`` example by `Katelyn FitzGerald`_ in (:pr:`173`)
* Additions to the examples gallery for ``set_titles_and_labels`` and ``set_axes_limits_and_ticks`` and updated thumbnail for ``plot_contour_labels`` by `Katelyn FitzGerald`_ in (:pr:`181`)

Bug Fixes
^^^^^^^^^
Expand Down
Loading