Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed Jun 28, 2023
1 parent e9edffb commit 2db86f0
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions examples/gallery/matplotlib/wind_barbs_example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import geoviews as gv\n",
"\n",
"gv.extension('matplotlib')\n",
"\n",
"gv.output(fig='svg', size=200)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Define data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lat = np.arange(60, 37.5, -2.5)\n",
"lon = np.arange(270, 292.5, 2.5)\n",
"uwnd = np.array(\n",
" [\n",
" [2, 0, -2, -2, -3, -3, -3, -2, -1],\n",
" [2, 0, -2, -2, -2, -2, -2, -1, 1],\n",
" [2, -1, -2, -2, -2, -1, 0, 1, 3],\n",
" [3, 0, -3, -5, -5, -4, -4, -2, 0],\n",
" [8, 4, 0, -3, -5, -6, -6, -6, -5],\n",
" [12, 10, 8, 5, 3, 0, -2, -2, -2],\n",
" [13, 14, 16, 16, 14, 12, 10, 9, 10],\n",
" [13, 18, 22, 24, 25, 24, 23, 22, 23],\n",
" [20, 25, 29, 32, 33, 32, 32, 33, 34],\n",
" ]\n",
")\n",
"vwwnd = np.array(\n",
" [\n",
" [3, 1, 0, -1, -1, 0, 1, 3, 4],\n",
" [-2, -3, -3, -2, 0, 2, 4, 6, 8],\n",
" [-6, -6, -4, -1, 2, 5, 7, 10, 12],\n",
" [-12, -10, -6, -1, 4, 7, 10, 12, 14],\n",
" [-17, -15, -10, -4, 2, 6, 9, 12, 16],\n",
" [-20, -18, -14, -8, -2, 2, 5, 10, 16],\n",
" [-17, -16, -13, -9, -6, -3, 1, 7, 15],\n",
" [-11, -10, -8, -6, -6, -5, -2, 6, 15],\n",
" [-5, -3, -2, -2, -4, -5, -2, 6, 15],\n",
" ]\n",
")\n",
"\n",
"wind_barbs = gv.WindBarbs.from_uv((lon, lat, uwnd, vwwnd)).opts(\n",
" fig_size=250, length=6.5, padding=1\n",
")\n",
"coastline = gv.feature.coastline()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plot"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"wind_barbs * coastline"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 2db86f0

Please sign in to comment.