aboutsummaryrefslogtreecommitdiff
path: root/docs/plot/plot.py
diff options
context:
space:
mode:
authorJuernjakob Dugge <juernjakob@gmail.com>2018-08-23 23:14:06 +0200
committerJuernjakob Dugge <juernjakob@gmail.com>2018-08-27 23:47:03 +0200
commit3378c5ec96fb3f067beffc6c3acd15765d5ce5d1 (patch)
treedbcfcf7e11fa3734e073136e1770cd3858de5936 /docs/plot/plot.py
parente1e7c15ef358ac516f06198c2832e7ab52e8dc20 (diff)
downloadPROJ-3378c5ec96fb3f067beffc6c3acd15765d5ce5d1.tar.gz
PROJ-3378c5ec96fb3f067beffc6c3acd15765d5ce5d1.zip
Ensure correct axis ratio for images in documentation; move proj-string from image to caption
Diffstat (limited to 'docs/plot/plot.py')
-rw-r--r--docs/plot/plot.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/docs/plot/plot.py b/docs/plot/plot.py
index 52bd7fd2..04a3d423 100644
--- a/docs/plot/plot.py
+++ b/docs/plot/plot.py
@@ -85,7 +85,7 @@ def interp_coords(coords, tol):
The function tries to densify a list of coordinates based on a simple measure.
If two adjacent points in the input coordinate list are further away from each
- other than the specified tolerance, the list will be densied between those two
+ other than the specified tolerance, the list will be densified between those two
points. Roughly speaking, a point will be inserted every `tol` between the
points.
@@ -230,7 +230,7 @@ def plotproj(plotdef, data, outdir):
'''
Plot map.
'''
- fig, axes = plt.subplots()
+ axes = plt.axes()
bounds = (plotdef['lonmin'], plotdef['latmin'], plotdef['lonmax'], plotdef['latmax'])
for geom in data.filter(bbox=bounds):
@@ -288,23 +288,30 @@ def plotproj(plotdef, data, outdir):
y = feature[:, 1]
axes.plot(x, y, color=COLOR_GRAT, linewidth=0.4)
- axes.axis('off')
+ # Switch off the axis lines...
+ plt.axis('off')
+ # ... and additionally switch off the visibility of the axis lines and
+ # labels so they can be removed by "bbox_inches='tight'" when saving
+ axes.get_xaxis().set_visible(False)
+ axes.get_yaxis().set_visible(False)
+
font = {
'family': 'serif',
'color': 'black',
'style': 'italic',
'size': 12
}
- fig.suptitle(plotdef['projstring'], fontdict=font)
- axes.autoscale(tight=True)
+ # Make sure the plot is not stretched
+ axes.set_aspect('equal')
+
if not os.path.exists(outdir):
os.makedirs(outdir)
- fig.savefig(outdir + '/' + plotdef['filename'], dpi=300)
+ plt.savefig(outdir + '/' + plotdef['filename'],
+ dpi=400,
+ bbox_inches='tight')
# Clean up
- fig = None
- del fig
axes = None
del axes
plt.close()