#!/usr/bin/env python # coding: utf-8 # # GMT/Python demo # # Demo of the [gmt-python](https://github.com/GenericMappingTools/gmt-python) package for Scipy 2017. # # Try to recreate a few plots from the [GMT Tutorial](http://gmt.soest.hawaii.edu/doc/latest/GMT_Tutorial.html). # In[1]: import gmt # Importing the module starts a mordern mode session. So there is no need to call `gmt begin` and `gmt end`. # # GMT creates a temporary directory where everything is stored. # In[2]: ls -d /tmp/gmt* # Start a new figure. # In[3]: gmt.figure() # Copy and modify some code from the tutorial: # # gmt pscoast -R-90/-70/0/20 -JM6i -P -Ba -Gchocolate > GMT_tut_3.ps # In[4]: gmt.pscoast(R='-90/-70/0/20', J="M6i", G='chocolate', B='a', P=True) # View the plot in the notebook: # In[5]: gmt.show() # Use aliases for the command-line arguments. # In[6]: help(gmt.pscoast) # In[7]: gmt.figure() gmt.pscoast(region='-90/-70/0/20', projection="M6i", land='chocolate', frame='a', portrait=True) gmt.show() # We automatically convert some arguments for you. # # Let's look at another command: # # gmt pscoast -R-130/-70/24/52 -JB-100/35/33/45/6i -Ba -B+t"Conic Projection" -N1/thickest -N2/thinnest -A500 -Ggray -Wthinnest -P > GMT_tut_4.ps # In[8]: gmt.figure() gmt.pscoast(region=[-130, -70, 24, 52], projection="B-100/35/33/45/6i", land='gray', frame='a', portrait=True, shorelines='thinnest', borders='1/thickest', area_thresh=500) gmt.show() # Lets plot some data! # # This example will not work entirely yet: # # gmt makecpt -Cred,green,blue -T0,70,300,10000 > quakes.cpt # gmt pscoast -R130/150/35/50 -JM6i -B5 -P -Ggray -K > GMT_tut_9.ps # gmt psxy -R -J -O @tut_quakes.ngdc -Wfaint -i4,3,5,6s0.1 -h3 -Scc -Cquakes.cpt >> GMT_tut_9.ps # In[9]: gmt.figure() gmt.pscoast(region=[130, 150, 35, 50], projection='M6i', frame=5, portrait=True, land='gray') gmt.psxy(data='@tut_quakes.ngdc', pen='faint', i='4,3', style='c0.2c', color='blue') gmt.show() # Save the figure to file: # In[10]: gmt.psconvert(prefix='my_figure', fmt='g', crop=True) # In[11]: ls *.png