Skip to content

Commit 1da44d5

Browse files
committed
Add gallery
1 parent 69efa0c commit 1da44d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1547
-6
lines changed

Project.toml

+1
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
2323
Rasters = "a3a2b9e3-a471-40c9-b274-f788e487c689"
2424
RasterDataSources = "3cb90ccd-e1b6-4867-9617-4276c8b2ca36"
2525
RemoteS = "26020ff4-e92a-488e-a723-09c28e89e04a"
26+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"

_css/gmt.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ ol {
311311
display: grid;
312312
grid-gap: 1em;
313313
justify-content: space-between;
314-
grid-template-columns: repeat(3, minmax(0, 1fr));
314+
grid-template-columns: repeat(4, minmax(0, 1fr));
315315
}
316316

317317
.box-container-2 {

_layout/masthead.html

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<a href="https://github.com/GenericMappingTools/GMTjl_doc"><img src="/assets/GitHub-Mark-64px.png" class="masthead-icon" /></a>
1212
</li>
1313
<li class="masthead__menu-item"><a href="/examples/">Examples</a></li>
14+
<li class="masthead__menu-item"><a href="/gallery/">Gallery</a></li>
1415
<li class="masthead__menu-item"><a href="/tutorials/">Tutorials</a></li>
1516
<li class="masthead__menu-item"><a href="/geophysics/">Geophysics</a></li>
1617
<li class="masthead__menu-item"><a href="/documentation/">Documentation</a></li>

_libs/lunr/lunr_index.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

documentation/modules/fill_between.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ same color as the line they sit on.
4747

4848
-----
4949
`fill_between(..., legend=...)`: If used as the above `labels` it behaves like wise, but its argument can
50-
also be a named tuple with `legend=(labels="Lab1,Lab2", position=poscode, box=(...))`, where `pscode`
51-
is the same as used in myreflink{text}, *e.g.* `TL` means *TopLeft* and `box` controls the legend box details.
50+
also be a named tuple with `legend=(labels="Lab1,Lab2", position=poscode, box=(...))`, where `poscode`
51+
is the same as used in \myreflink{text}, *e.g.* `TL` means *TopLeft* and `box` controls the legend box details.
5252
See [examples at](https://www.generic-mapping-tools.org/GMTjl_doc/examples/legends/01_legends)
5353

5454
-----

gallery/ex01.md

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Contour maps
2+
3+
We want to create two contour maps of the low order geoid using the Hammer equal area projection.
4+
Our gridded data file is called ``osu91a1f_16.nc`` and contains a global 1 by 1 gridded geoid
5+
(we will see how to make gridded files later). We would like to show one map centered on Greenwich
6+
and one centered on the dateline. Positive contours should be drawn with a solid pen and negative
7+
contours with a dashed pen. Annotations should occur for every 50 m contour level, and both contour
8+
maps should show the continents in light brown in the background. This is how it is done:
9+
10+
11+
\begin{examplefig}{}
12+
```julia
13+
using GMT
14+
GMT.resetGMT() # hide
15+
16+
subplot(grid=(2,1), region=:global, autolabel=true, margins=0.5,
17+
title="Low Order Geoid", panel_size=(16,0), frame="lrtb", proj=:Hammer, figsize=16)
18+
gmtset(MAP_GRID_CROSS_SIZE_PRIMARY=0, FONT_ANNOT_PRIMARY=10, PS_CHAR_ENCODING="Standard+")
19+
coast(frame="afg", land=:lightbrown, water=:lightblue)
20+
grdcontour("@osu91a1f_16.nc", cont=10, annot=(int=50,labels=(font=7,)), labels=(dist=10,),
21+
range=(-1000,-1), pen=((contour=1,pen="thinnest,-"), (annot=1, pen="thin,-")),
22+
ticks=(gap=(0.25,0.05),labels=""))
23+
grdcontour("@osu91a1f_16.nc", cont=10, annot=(int=50,labels=(font=7,)), labels=(dist=10,),
24+
range=(-1,100), ticks=(gap=(0.25,0.05),labels=""))
25+
26+
coast(frame="afg", land=:lightbrown, water=:lightblue, panel=(2,1))
27+
grdcontour("@osu91a1f_16.nc", cont=10, annot=(int=50,labels=(font=7,)), labels=(dist=10,),
28+
range=(-1000,-1), pen=((contour=1,pen="thinnest,-"), (annot=1, pen="thin,-")),
29+
ticks=(gap=(0.25,0.05),))
30+
grdcontour("@osu91a1f_16.nc", cont=10, annot=(int=50,labels=(font=7,)), labels=(dist=10,),
31+
range=(-1,1000), ticks=(gap=(0.25,0.05),))
32+
subplot("show")
33+
```
34+
\end{examplefig}
35+
36+
The first command sets up a 2 by 1 subplot layout. The subplot determines the size of what map can fit so we use?
37+
when specifying map widths in the commands below. This initial setup is followed by two sequences of \myreflink{coast}
38+
\myreflink{grdcontour}, \myreflink{grdcontour}. They differ in that the first is centered on the dateline,
39+
while the second on Greenwich. We use the **range** option in grdcontour to select negative contours only and
40+
plot those with a dashed pen, then positive contours only and draw with a solid pen [Default]. The **ticks** option
41+
causes tick marks pointing in the downhill direction to be drawn on the innermost, closed contours. For the upper
42+
panel we also added - and + to the local lows and highs. The labeling of the two plots with a) and b) is
43+
automatically done by \myreflink{subplot}.

gallery/ex02.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# (2) Image presentations
2+
3+
As our second example we will demonstrate how to make color images from gridded data sets (again, we will
4+
defer the actual making of grid files to later examples). We have prepared two 2-D grid files of bathymetry
5+
and Geosat geoid heights from global grids and will put the two images on the same page. The region of
6+
interest is the Hawaiian Islands, and due to the oblique trend of the island chain we prefer to rotate
7+
our geographical data sets using an oblique Mercator projection defined by the hotspot pole at (68W, 69N).
8+
We choose the point (190, 25.5) to be the center of our projection (e.g., the local origin), and we want
9+
to image a rectangular region defined by the longitudes and latitudes of the lower left and upper right
10+
corner of region. In our case we choose (160, 20) and (220, 30) as the corners. We twice use \myreflink{grdimage} to make the illustration:
11+
12+
\begin{examplefig}{}
13+
```julia
14+
using GMT
15+
GMT.resetGMT() # hide
16+
17+
gmtset(FONT_TITLE=30, MAP_ANNOT_OBLIQUE=0)
18+
g_cpt = makecpt(color=:rainbow, T=(-2,14,2))
19+
grdimage("@HI_geoid_02.nc", region_diag=(160,220,20,30),
20+
proj=(name=:omercp, center=[190 25.5], parallels=[292 69]),
21+
dpi=50, frame=(annot=10,), xshift=3.8, yshift=3.2, figsize=12)
22+
colorbar!(pos=(anchor=:RM, offset=(1.5,0), triangles=true, neon=true),
23+
xaxis=(annot=2, label=:GEOID), yaxis=(label=:m,))
24+
25+
# Now the topography map
26+
t_cpt = grd2cpt("@HI_topo_02.nc", cmap=:relief, continuous=true)
27+
grdimage!("@HI_topo_02.nc", frame=(title="H@#awaiian@# T@#opo and @#G@#eoid@#", annot=10),
28+
shade="+a0", dpi=50, yshift=11, par=(:MAP_TITLE_OFFSET, 1.25))
29+
colorbar!(pos=(anchor=:RM, offset=(1.5,0), neon=true), shade=0.3,
30+
xaxis=(annot=2, label=:TOPO), yaxis=(label=:km,))
31+
T = mat2ds([-0.4 7.5; -0.4 3.0], ["a)", "b)"])
32+
pstext!(T, region=(0,21.6,0,29.94), font=(30,"Helvetica-Bold"), justify=:CB,
33+
yshift=11, proj=:linear, scale=1, show=true)
34+
```
35+
\end{examplefig}
36+
37+
38+
We again set up a 2 by 1 subplot layout and specify the actual region and map projection we wish to use
39+
for the two map panels. We use \myreflink{makecpt} to generate a linear color palette file for the geoid
40+
and use \myreflink{grd2cpt} to get a histogram-equalized CPT for the topography data. We run \myreflink{grdimage}
41+
to create a color-coded image of the topography, and to emphasize the structures in the data we use the slopes
42+
in the north-south direction to modulate the color image via the **shade** option. Then, we place a color
43+
legend to the right of the image with \myreflink{colorbar}. We repeat these steps for the Geosat geoid grid.
44+
Again, the labeling of the two plots with a) and b) is automatically done by \myreflink{subplot}.

gallery/ex04.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# (4) A 3-D perspective mesh plot
2+
3+
This example will illustrate how to make a fairly complicated composite figure. We need a subset of
4+
the ETOPO5 bathymetry 1 and Geosat geoid data sets which we have extracted from the global data grids
5+
using grdcut and access those files here as remote files on the GMT data server. We would like to
6+
show a 2-layer perspective plot where layer one shows a contour map of the marine geoid with the
7+
location of the Hawaiian islands superposed, and a second layer showing the 3-D mesh plot of the
8+
topography. We also add an arrow pointing north and some text. The first part of this script shows how to do it:
9+
10+
\begin{examplefig}{}
11+
```julia
12+
using GMT
13+
GMT.resetGMT() # hide
14+
15+
makecpt(cmap=(255,100), range=(-10,10,10), no_bg=true);
16+
grdcontour("@HI_geoid_04.nc", region=(195,210,18,25), view=(60,30), cont=1,
17+
annot=(int=5, labels=(rounded=true,)), labels=(dist=10,),
18+
xshift=3, yshift=3, proj=:merc, figscale=1.1)
19+
coast!(p=true, frame=(annot=2, axes=:NEsw), land=:black,
20+
rose=(inside=true, anchor=:BR, width=2.5, offset=0.25, label=true))
21+
grdview!("@HI_topo_04.nc", p=true, region=(195,210,18,25,-6,4),
22+
plane=(-6,:lightgray), surftype=(surf=true, mesh=true), Jz="0.9",
23+
frame=(axes=:wesnZ, annot=2), zaxis=(annot=2, label="Topo (km)"), yshift=5.6)
24+
text!("H@#awaiian@# R@#idge@#", x=7.5, y=14.0, region=(0,21,0,28),
25+
font=(60,"ZapfChancery-MediumItalic"), justify=:CB, proj=:linear,
26+
view=:none, figscale=1, show=true)
27+
```
28+
\end{examplefig}
29+
30+
The purpose of the CPT zero.cpt is to have the positive topography mesh painted light gray
31+
(the remainder is white). The left side of Figure shows the complete illustration.
32+
33+
The second part of the script shows how to make the color version of this figure that was printed
34+
in our first article in EOS Trans. AGU (8 October 1991). Using \myreflink{grdview} one can choose
35+
to either plot a mesh surface (left) or a color-coded surface (right). We have also added artificial
36+
illumination from a light-source due north, which is simulated by computing the gradient of the surface
37+
grid in that direction though the \myreflink{grdgradient} program. We choose to use the -Qc option in
38+
\myreflink{grdview} to achieve a high degree of smoothness. Here, we select 100 dpi since that will be
39+
the resolution of our final raster (The EOS raster was 300 dpi). Note that the size of the resulting
40+
output file is directly dependent on the square of the dpi chosen for the scanline conversion and how
41+
well the resulting image compresses. A higher value for dpi in -Qc would have resulted in a much larger
42+
output file. The CPTs were taken from Example (2) Image presentations.

gallery/ex05.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# (5) A 3-D illuminated surface (in bw)
2+
3+
Instead of a mesh plot we may choose to show 3-D surfaces using artificial illumination. For this
4+
example we will use grdmath to make a grid file that contains the surface given by the function , where .
5+
The illumination is obtained by passing the grid file to \myreflink{grdview} and requesting that
6+
artificial shading be derived from the horizontal gradients in the direction of the artificial
7+
light source. The \myreflink{makecpt} command creates a simple color scheme for a constant gray
8+
level of 128. Thus, variations in shade are entirely due to variations in gradients, or illuminations.
9+
We choose to illuminate from the SW and view the surface from SE:
10+
11+
The variations in intensity could be made more dramatic by using grdmath to scale the intensity file
12+
before running \myreflink{grdview}. For very rough data sets one may improve the smoothness of the
13+
intensities by computing them first with \myreflink{grdgradient} and then pass them to \myreflink{grdhisteq}.
14+
The shell-script above will result in a plot like the one in Figure.
15+
16+
\begin{examplefig}{}
17+
```julia
18+
using GMT
19+
resetGMT() # hide
20+
21+
Gsombrero = gmt("grdmath -R-15/15/-15/15 -I0.3 X Y HYPOT DUP 2 MUL PI MUL 8 DIV COS EXCH NEG 10 DIV EXP MUL =");
22+
C = makecpt(color=128, range=(-5,5), no_bg=true);
23+
grdview(Gsombrero, limits=(-15,15,-15,15,-1,1), frame=(axes="SEwnZ", annot=5),
24+
zaxis=(annot=0.5,), plane=(-1, :white), surftype=:surface,
25+
shade=(azim=225, norm="t0.75"), figsize=12, zsize=5, view=(120,30))
26+
tit = mat2ds([7.5 12], "z(r) = cos (2@~p@~r/8) @~\\327@~e@+-r/10@+");
27+
text!(tit, limits=(0,21,0,28), proj=:linear, view=:none,
28+
font=(50,"ZapfChancery-MediumItalic"), justify=:CB, scale=1, show=true)
29+
```
30+
\end{examplefig}

gallery/ex06.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# (6) Plotting of histograms
2+
3+
GMT provides two tools to render histograms: \myreflink{histogram} and \myreflink{rose}.
4+
The former takes care of regular histograms whereas the latter deals with polar histograms
5+
(rose diagrams, sector diagrams, and wind rose diagrams). We will show an example that involves
6+
both programs. The remote file ``fractures_06.txt`` contains a compilation of fracture lengths
7+
and directions as digitized from geological maps. The remote file ``v3206_06.txt`` contains
8+
all the bathymetry measurements from Vema cruise 3206. Our complete figure was made as a 2 by 1
9+
\myreflink{subplot} figure by running this script:
10+
11+
\begin{examplefig}{}
12+
```julia
13+
using GMT
14+
GMT.resetGMT() # hide
15+
16+
subplot(grid=(2,1), autolabel=(Anchor=:TL, offset=0.8), margins=1, panel_size=(15,9))
17+
histogram!("@v3206_06.txt", limits=(-6000,0,0,30), pen=1, yaxis=(label=:Frequency, suffix=" %"),
18+
axis=(axes=:WSne, title=:Histograms, xlabel="Topography (m)", fill=:lightblue), fill=:orange, kind=(freq=true,), bin=250)
19+
20+
rose(panel=:next, "@fractures_06.txt", limits=(0,1,0,360), swap_xy=true, sector=(width=10, rose=true),
21+
norm=true, fill=:orange, axis=(grid=:auto, fill=:lightblue,), pen=1)
22+
subplot("show")
23+
```
24+
\end{examplefig}

gallery/ex07.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
(7) A simple location map
2+
3+
Many scientific papers start out by showing a location map of the region of interest. This map will
4+
typically also contain certain features and labels. This example will present a location map for the
5+
equatorial Atlantic ocean, where fracture zones and mid-ocean ridge segments have been plotted.
6+
We also would like to plot earthquake locations and available isochrons. We have obtained one file,
7+
``quakes_07.txt``, which contains the position and magnitude of available earthquakes in the region.
8+
We choose to use magnitude/40 for the symbol-size in cm. The digital fracture zone traces (``fz_07.txt``)
9+
and isochrons (0 isochron as ``ridge_07.txt``, the rest as ``isochron_07.txt``) were digitized from
10+
available maps 1. We create the final location map with the following script:
11+
12+
13+
\begin{examplefig}{}
14+
```julia
15+
using GMT
16+
GMT.resetGMT() # hide
17+
18+
coast(region=(-50,0,-10,20), water=:lightblue, land="P300/26:FtanBdarkbrown",
19+
res=:low, shore=:thinnest, frame=(annot=10,), proj=:Mercator, figsize=18,
20+
par=(:FORMAT_GEO_MAP, :dddF))
21+
plot!("@fz_07.txt", pen="thinner,-")
22+
scatter!("@quakes_07.txt", h=1, i="0,1,2s0.01", marker=:circle, fill=:red,
23+
markerline=:thinnest, MarkerSize="3p")
24+
plot!("@isochron_07.txt", pen="thin,blue")
25+
plot!("@ridge_07.txt", pen=(:thicker,:orange))
26+
legend!(mat2ds("S 0.25 c 0.2 red thinnest 0.5 ISC Earthquakes"),
27+
pos=(inside=true, anchor=:TR, width=5.0, offset=0.5),
28+
box=(pen=:thick,inner=:thinner,fill=:white),
29+
par=(:FONT_ANNOT_PRIMARY, "16p,Times-Italic"))
30+
text!(mat2ds([-43 -5; -43 -8; -7 11], ["SOUTH", "AMERICA", "AFRICA"]),
31+
font=(20,"Helvetica-Bold","white=thin"), show=true)
32+
```
33+
\end{examplefig}

gallery/ex08.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# (8) A 3-D histogram
2+
3+
The program \myreflink{plot3d} allows us to plot three-dimensional symbols, including columnar plots.
4+
As a simple demonstration, we will convert a gridded netCDF of bathymetry into an ASCII xyz table and
5+
use the height information to draw a 2-D histogram in a 3-D perspective view. We also use the height
6+
information to set to color of each column via a CPT file. Our gridded bathymetry file is the 5 arc-minute
7+
global relief. Depth ranges from -5000 meter to sea-level. We produce the Figure by running this script:
8+
9+
10+
\begin{examplefig}{}
11+
```julia
12+
using GMT
13+
GMT.resetGMT() # hide
14+
15+
C = makecpt(color=:cubhelix, T=(-5000,0))
16+
bar3(gmtread("@earth_relief_05m_g", region=(0,5,0,5)), region=(0,5,0,5,-5000,0), base=-5000,
17+
frame=(annot=1, axes=:WSneZ, title=:ETOPO5, cube=true),
18+
zaxis=(annot=1000, label="Topography (m)"), color=C,
19+
lw=:thinnest, proj=:Mercator, figsize=12, zsize=13, view=(200,30))
20+
text!(mat2ds([0.1 4.7], "This is the surface of cube"), JZ=true, Z=0,
21+
font=(24,"Helvetica-Bold"), justify=:TL, show=true)
22+
```
23+
\end{examplefig}

gallery/ex09.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# (9) Time-series along tracks
2+
3+
A common application in many scientific disciplines involves plotting one or several time-series as as
4+
*“wiggles”* along tracks. Marine geophysicists often display magnetic anomalies in this manner, and
5+
seismologists use the technique when plotting individual seismic traces. In our example we will show
6+
how a set of Geosat sea surface slope profiles from the south Pacific can be plotted as “wiggles”
7+
using the \myreflink{wiggle} program. We will embellish the plot with track numbers, the location of
8+
the Pacific-Antarctic Ridge, recognized fracture zones in the area, and a “wiggle” scale. The Geosat
9+
tracks are stored in the file ``tracks_09.txt``, the ridge in ``ridge_09.txt``, and all the fracture
10+
zones are stored in the multiple segment file ``fz_09.txt``. The profile id is contained in the segment
11+
headers and we wish to use the last data point in each of the track segments to construct an input file
12+
for text that will label each profile with the track number. We know the profiles trend approximately N40E
13+
so we want the labels to have that same orientation (i.e., the angle with the baseline must be 50).
14+
We do this by extracting the last record from each track and select segment header as textstring when
15+
running the output through text. Note we offset the text positions in order to have a small gap
16+
between the profile and the label:
17+
18+
\begin{examplefig}{}
19+
```julia
20+
using GMT
21+
GMT.resetGMT() # hide
22+
23+
wiggle("@tracks_09.txt", limits=(185,250,-68,-42), proj=:Mercator, figscale=0.27,
24+
frame=(axes=:WSne, annot=10, ticks=5, fill=[240 255 240]), G="+red -G-blue",
25+
D="jBR+w500+l@~m@~rad+o0.5", ampscale=800, pen=:thinnest, par=(:FORMAT_GEO_MAP,:dddF))
26+
plot!("@ridge_09.txt", pen=:thicker)
27+
plot!("@fz_09.txt", pen="thinner,-")
28+
29+
# Take label from segment header and plot near coordinates of last record of each track
30+
t = gmtconvert("@tracks_09.txt", E=:l)
31+
for k = 1:length(t) t[k].text = [t[k].header] end
32+
text!(t, font=(8,"Helvetica-Bold"), angle=50, justify=:RM, header=true,
33+
offset=(-0.1,-0.1), show=true)
34+
```
35+
\end{examplefig}

gallery/ex10.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# (10) A geographical bar graph plot
2+
3+
Our next and perhaps most business-like example presents a three-dimensional bar graph plot showing the geographic
4+
distribution of all the languages of the world. The input data was taken from [Ethnologue](https://www.ethnologue.com/).
5+
We decide to plot a 3-D multi-band column centered on each continent with a height that is proportional to the
6+
languages used. We choose a plain linear projection for the basemap and add the multi-band columns and text on top.
7+
The different bands in the columns indicate how commonly the languages are used, from institutional languages to
8+
languages threatened by extinction. The script also shows how to effectively use transparency of the boxes around
9+
the numbers and in the shade surrounding the legend. Our script that produces Figure 10 reads:
10+
11+
12+
\begin{examplefig}{}
13+
```julia
14+
using GMT
15+
GMT.resetGMT() # hide
16+
17+
coast(region=:global, shore=:faint, land=:wheat, ocean=:azure2, area=5000,
18+
view=(200,40), proj=(name=:PlateCarree, center=(0,37.5)))
19+
D = gmtread("@languages_10.txt")
20+
text!(vec(string.(Int.(sum(D[:, 3:end], dims=2)))), x=D[:,1], y=D[:,2], # Sum by continents
21+
font=(20,"Helvetica-Bold","firebrick=thinner"), justify=:RM, fill="white@30", offset=(-0.6,0))
22+
cpt = makecpt(color=(:purple, :blue, :darkgreen, :yellow, :red), range="0,1,2,3,4,5")
23+
bar3!(D, region=(-180,180,-90,90,0,2500), color=cpt, bar=(width=0.6, Nbands=5),
24+
frame=(axes=:WSneZ, annot=:auto, ticks=:auto, title="World Languages By Continent"),
25+
zaxis=(annot=500, label=:Languages), fill=:purple, lw=:thinner, zsize=8,
26+
par=(FONT_TITLE="30p,Times-Bold", MAP_TITLE_OFFSET=-1.8, FORMAT_GEO_MAP=:dddF), view=(200,40))
27+
legend!("@legend_10.txt", JZ=true, pos=(anchor=:LB, width=3.5, justify=:LB, offset=0.5),
28+
par=(:FONT,"Helvetica-Bold"),
29+
box=(fill=:lightgrey, pen=:thinner, shaded="-4p/-6p/grey20@40"), show=true)
30+
```
31+
\end{examplefig}

0 commit comments

Comments
 (0)