Plot data on ternary diagrams


gmt ternary [ table ] [ -JX[-]width ] [ -Ramin/amax/bmin/bmax/cmin/cmax ] [ -B[p|s]parameters ] [ -Ccpt ] [ -Gfill ] [ -La/b/c ] [ -M ] [ -N ] [ -S[symbol][size] ] [ -U[stamp] ] [ -V[level] ] [ -W[pen][attr] ] [ -X[a|c|f|r][xshift] ] [ -Y[a|c|f|r][yshift] ] [ -bibinary ] [ -dinodata[+ccol] ] [ -eregexp ] [ -fflags ] [ -ggaps ] [ -hheaders ] [ -iflags ] [ -pflags ] [ -qiflags ] [ -sflags ] [ -ttransp ] [ -:[i|o] ] [ --PAR=value ]


Reads (a,b,c[,z]) records from table [or standard input] and plots symbols at those locations on a ternary diagram. If a symbol is selected and no symbol size given, then we will interpret the fourth column of the input data as symbol size. Symbols whose size \(\leq 0\) are skipped. If no symbols are specified then the symbol code (see -S below) must be present as last column in the input. If -S is not specified then we instead plot lines or polygons.

Required Arguments

Either -M (for dumping data) or -R and -J must be selected.


One or more ASCII (or binary, see -bi[ncols][type]) data table file(s) holding a number of data columns. If no tables are given then we read from standard input.

Optional Arguments


For ternary diagrams the three sides are referred to as a, b, and c. Thus, to give specific settings for one of these axis you must include the axis letter before the arguments. If all axes have the same arguments then only give one option without the axis letter. For more details, see the -B discussion in basemap.


Give a CPT or specify -Ccolor1,color2[,color3,…] to build a linear continuous CPT from those colors automatically. In this case colorn can be a r/g/b triplet, a color name, or an HTML hexadecimal color (e.g. #aabbcc ). If -S is set, let symbol fill color be determined by the z-value in the fourth column. Additional fields are shifted over by one column (optional size would be 5th rather than 4th field, etc.). If modern mode and no argument is given then we select the current CPT.

-Gfill (more …)

Select color or pattern for filling of symbols [Default is no fill]. Note that we will search for -G and -W strings in all the segment headers and let any values thus found over-ride the command line settings.


The only valid projection is linear plot with specified ternary width. Use a negative width to indicate that positive axes directions be clock-wise [Default lets the a, b, c axes be positive in a counter-clockwise direction].


Set the labels for the three diagram vertices where the component is 100% [none]. These are placed at a distance of three times the MAP_LABEL_OFFSET setting from their respective corners. To skip any one of them, specify that label as -.


Do no plotting. Instead, convert the input (a,b,c[,z]) records to Cartesian (x,y,[,z]) records, where x, y are normalized coordinates on the triangle (i.e., 0–1 in x and 0–sqrt(3)/2 in y).


Do not clip symbols that fall outside map border [Default plots points whose coordinates are strictly inside the map border only].


Give the min and max limits for each of the three axis a, b, and c.


Plot individual symbols in a ternary diagram. If -S is not given then we will instead plot lines (requires -W) or polygons (requires -C or -G). If present, size is symbol size in the unit set by PROJ_LENGTH_UNIT (unless c, i, or p is appended). If the symbol code (see below) is not given it will be read from the last column in the input data; this cannot be used in conjunction with binary input. Optionally, append c, i, or p to indicate that the size information in the input data is in units of cm, inch, or point, respectively [Default is PROJ_LENGTH_UNIT]. Note: If you provide both size and symbol via the input file you must use PROJ_LENGTH_UNIT to indicate the unit used for the symbol size or append the units to the sizes in the file. If symbol sizes are expected via the third data column then you may convert those values to suitable symbol sizes via the -i mechanism. The general input expectations are:

coordinates [ value ] [ parameters ] [ symbol ]

where coordinates is two or three columns specifying the location of a point, the optional value is required when -C is used to control color, the optional parameters is required when no symbol size is specified, and the trailing text with leading symbol code is required when the symbol code is not specified on the command line. Note: parameters may represent more than one size column as some symbols require several parameters to be defined (e.g., a circle just needs one column, a rectangle needs two dimensions, while an ellipse needs an orientation and two dimensions, and so on); see specifics below. When there is only a single parameter we will refer to it as size.

The uppercase symbols A, C, D, G, H, I, N, S, T are normalized to have the same area as a circle with diameter size, while the size of the corresponding lowercase symbols refers to the diameter of a circumscribed circle.

You can change symbols by adding the required -S option to any of your multi-segment headers.

Choose between these symbol codes:


x-dash (-). size is the length of a short horizontal (x-dir) line segment.


plus (+). size is diameter of circumscribing circle.


star. size is diameter of circumscribing circle.


circle. size is diameter of circle.


diamond. size is diameter of circumscribing circle.


ellipse. If not given, then direction (in degrees counter-clockwise from horizontal), major_axis, and minor_axis must be found after the location [and value] columns. If only a single size is given then we plot a degenerate ellipse (circle) with given diameter.


octagon. size is diameter of circumscribing circle.


hexagon. size is diameter of circumscribing circle.


inverted triangle. size is diameter of circumscribing circle.


Rotated rectangle. If not given, then direction (in degrees counter-clockwise from horizontal), width, and height must be found after the location [and value] columns. If only a single size is given then we plot a degenerate rectangle (square) with given size.


kustom symbol. We will look for a symbol definition file called name.def in (1) the current directory, (2) in ~/.gmt or (3) in $GMT_SHAREDIR/custom. The symbol defined in the definition file is of normalized unit size by default; the appended size will scale the symbol accordingly. Users may create their own custom *.def files; see Custom Symbols. Alternatively, you can supply an EPS file instead of a *.def file and we will scale and place that graphic as a symbol.


letter or text string (less than 256 characters). Give size, and append +tstring after the size. Note that the size is only approximate; no individual scaling is done for different characters. Remember to escape special characters like *. Optionally, you may append +ffont to select a particular font [Default is FONT_ANNOT_PRIMARY] and +jjustify to change justification [CM].


pentagon. size is diameter of circumscribing circle.


point. No size needs to be specified (1 pixel is used).


rectangle. If width/height are not given, then these dimensions must be found after the location [and value] columns. Alternatively, append +s and then the diagonal corner coordinates are expected after the location [and value] columns instead.


Rounded rectangle. If width/height/radius are not given, then the two dimensions and corner radius must be found after the location [and value] columns.


square. size is diameter of circumscribing circle.


triangle. size is diameter of circumscribing circle.


Pie wedge. Give the outer diameter outer, startdir and stopdir. These are directions (in degrees counter-clockwise from horizontal) for wedge. Parameters not appended are read from file after the location [and value] columns. Append +i and append a nonzero inner diameter inner or it will be read last [0]. Append +a[dr] to draw the arc line (at inner and outer diameter); if dr is appended then we draw all arc lines separated radially by dr. Append +r[da] to draw radial lines (at start and stop directions) if da is appended then we draw all radial lines separated angularly by da. These spider-web lines are drawn using the current pen unless +ppen is added.


cross (x). size is diameter of circumscribing circle.


y-dash (|). size is the length of a short vertical (y-dir) line segment.


Draw GMT time stamp logo on plot. (See full description) (See cookbook information).


Select verbosity level [w]. (See full description) (See cookbook information).

-W[pen][attr] (more …)

Set pen attributes for the outline of symbols.


Shift plot origin. (See full description) (See cookbook information).


Shift plot origin. (See full description) (See cookbook information).

-birecord[+b|l] (more …)

Select native binary format for primary table input. [Default is the required number of columns given the chosen settings].

-dinodata[+ccol] (more …)

Replace input columns that equal nodata with NaN.

-e[~]“pattern” | -e[~]/regexp/[i] (more …)

Only accept data records that match the given pattern.

-f[i|o]colinfo (more …)

Specify data types of input and/or output columns.

-gx|y|z|d|X|Y|Dgap[u][+a][+ccol][+n|p] (more …)

Determine data gaps and line breaks. The -g option is ignored if -S is set.

-h[i|o][n][+c][+d][+msegheader][+rremark][+ttitle] (more …)

Skip or produce header record(s).

-icols[+l][+ddivisor][+sscale|d|k][+ooffset][,][,t[word]] (more …)

Select input columns and transformations (0 is first column, t is trailing text, append word to read one word only).

-qi[~]rows|limits[+ccol][+a|t|s] (more …)

Select input rows or data limit(s) [default is all rows].

-s[cols][+a][+r] (more …)

Set handling of NaN records for output.

-:[i|o] (more …)

Swap 1st and 2nd column on input and/or output.

-p[x|y|z]azim[/elev[/zlevel]][+wlon0/lat0[/z0]][+vx0/y0] (more …)

Select perspective view.

-ttransp[/transp2] (more …)

Set transparency level(s) in percent.

-^ or just -

Print a short message about the syntax of the command, then exit (Note: on Windows just use -).

-+ or just +

Print an extensive usage (help) message, including the explanation of any module-specific option (but not the GMT common options), then exit.

-? or no arguments

Print a complete usage (help) message, including the explanation of all options, then exit.


Temporarily override a GMT default setting; repeatable. See gmt.conf for parameters.


To plot circles (diameter = 0.1 cm) on a 15-centimeter-wide ternary diagram at the positions listed in the file ternary.txt, with default annotations and gridline spacings, using the specified labeling, try:

gmt begin map
  gmt makecpt -Cturbo -T0/80/10
  gmt ternary @ternary.txt -R0/100/0/100/0/100 -JX15c -Sc0.1c -C -LLimestone/Water/Air \
    -Baafg+l"Limestone component"+u" %" -Bbafg+l"Water component"+u" %" -Bcagf+l"Air component"+u" %" \
    -B+givory+t"Example data from MATLAB Central"
gmt end show

See Also

gmt, gmt.conf, gmtcolors, basemap, plot, plot3d