Skip to content

Commit f0bc1ad

Browse files
Monorail map example: add border using figure edge + tidy comments
1 parent e98d6ed commit f0bc1ad

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

examples/miscellanea/simpsons-monorail-map.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import cartopy.crs as ccrs
2424
import cartopy.io.shapereader as shpreader
25+
from matplotlib.patches import Rectangle
2526

2627

2728
# Define choices for projection and locations to plot
@@ -37,10 +38,16 @@
3738

3839

3940
def main():
40-
# Set up a plot with a thin light blue/white border to make the map inside
41-
# Note: for proportions of land mass, font size and border to be as
42-
# intended, need to keep 'figsize' and 'dpi' (4:3 ratio) as below.
43-
fig = plt.figure(figsize=(9, 7.5), dpi=125, facecolor="#AFCBBD")
41+
# Set up a plot with a light blue background and a white overall border.
42+
# For proportions of land mass, font size and border to be as
43+
# intended, need to keep 'figsize' and 'dpi' (4:3 ratio) as below.
44+
fig = plt.figure(
45+
figsize=(9, 7.5),
46+
dpi=125,
47+
facecolor="#AFCBBD",
48+
edgecolor="white", # sets up white border without need for another axes
49+
linewidth=30, # makes the border thicker as per original map
50+
)
4451
map_ax = fig.add_axes(
4552
[0.035, 0.035, 0.93, 0.93], projection=ccrs.LambertConformal(), frameon=False
4653
)
@@ -66,10 +73,8 @@ def main():
6673
edgecolor="black",
6774
)
6875

69-
# From/see example:
70-
# https://scitools.org.uk/cartopy/docs/latest/gallery/
71-
# scalar_data/eyja_volcano.html
72-
# Now add the location labels
76+
# Now add the location labels. The general approach is that covered in
77+
# the 'Map tile acquisition' Catopy example, including the comment below.
7378
#
7479
# Use the cartopy interface to create a matplotlib transform object
7580
# for the Geodetic coordinate system. We will use this along with
@@ -111,10 +116,10 @@ def main():
111116
"(recreation of map at\nsimpsons.fandom.com/\nwiki/Brockway)"
112117
)
113118

114-
# Add the 'compass' legend
119+
# Add the bottom left 'compass' legend in spirit of the original map.
115120
map_ax.text(
116121
0.14,
117-
0.10,
122+
0.0,
118123
leg_text,
119124
transform=map_ax.transAxes,
120125
fontsize=11,

0 commit comments

Comments
 (0)