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 #1726 from obspy/custom_basemap_example
Tutorial: add example for custom basemap plot with Inventory/Catalog
- Loading branch information
Showing
2 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
misc/docs/source/tutorial/code_snippets/basemap_plot_custom.py
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,36 @@ | ||
from mpl_toolkits.basemap import Basemap | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
from obspy import read_inventory, read_events | ||
|
||
# Set up a custom basemap, example is taken from basemap users' manual | ||
fig, ax = plt.subplots() | ||
|
||
# setup albers equal area conic basemap | ||
# lat_1 is first standard parallel. | ||
# lat_2 is second standard parallel. | ||
# lon_0, lat_0 is central point. | ||
m = Basemap(width=8000000, height=7000000, | ||
resolution='c', projection='aea', | ||
lat_1=40., lat_2=60, lon_0=35, lat_0=50, ax=ax) | ||
m.drawcoastlines() | ||
m.drawcountries() | ||
m.fillcontinents(color='wheat', lake_color='skyblue') | ||
# draw parallels and meridians. | ||
m.drawparallels(np.arange(-80., 81., 20.)) | ||
m.drawmeridians(np.arange(-180., 181., 20.)) | ||
m.drawmapboundary(fill_color='skyblue') | ||
ax.set_title("Albers Equal Area Projection") | ||
|
||
# we need to attach the basemap object to the figure, so that obspy knows about | ||
# it and reuses it | ||
fig.bmap = m | ||
|
||
# now let's plot some data on the custom basemap: | ||
inv = read_inventory() | ||
inv.plot(fig=fig, show=False) | ||
cat = read_events() | ||
cat.plot(fig=fig, show=False, title="", colorbar=False) | ||
|
||
plt.show() |
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