OSGeoLive-Notebooks/Cartopy/cartopy-favicon.ipynb

87 lines
2.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import cartopy.crs as ccrs\n",
"import matplotlib.pyplot as plt\n",
"import matplotlib.textpath\n",
"import matplotlib.patches\n",
"from matplotlib.font_manager import FontProperties\n",
"import numpy as np\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"\n",
"def main():\n",
" fig = plt.figure(figsize=[8, 8])\n",
" ax = fig.add_subplot(1, 1, 1, projection=ccrs.SouthPolarStereo())\n",
"\n",
" ax.coastlines()\n",
" ax.gridlines()\n",
" ax.stock_img()\n",
"\n",
" # Generate a matplotlib path representing the character 'C'.\n",
" fp = FontProperties(family='DejaVu Sans', weight='bold')\n",
" logo_path = matplotlib.textpath.TextPath((-4.5e7, -3.7e7),\n",
" 'C', size=103250000, prop=fp)\n",
"\n",
" # Add the path as a patch, drawing black outlines around the text.\n",
" patch = matplotlib.patches.PathPatch(logo_path, facecolor='white',\n",
" edgecolor='black', linewidth=10,\n",
" transform=ccrs.SouthPolarStereo())\n",
" ax.add_patch(patch)\n",
" plt.show()\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"main()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.8.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}