diff --git a/doc/examples/ex03/ex03.ps b/doc/examples/ex03/ex03.ps index d6ed8167eae..dff50c5522c 100644 Binary files a/doc/examples/ex03/ex03.ps and b/doc/examples/ex03/ex03.ps differ diff --git a/doc/examples/ex03/ex03.sh b/doc/examples/ex03/ex03.sh index f509f8de392..26d35afc7e6 100755 --- a/doc/examples/ex03/ex03.sh +++ b/doc/examples/ex03/ex03.sh @@ -42,16 +42,13 @@ gmt begin ex03 # Now to do the cross-spectra, assuming that the ship is the input and the sat is the output # data, we do this: gmt convert -A samp_ship.pg samp_sat.pg -o1,3 | gmt spectrum1d -S256 -D1 -W -C -T - # Time to plot spectra + # Time to plot spectra, use -l to build a legend gmt set FONT_TAG 18p,Helvetica-Bold gmt subplot begin 2x1 -M0.1i -SCb+l"Wavelength (km)" -T"Ship and Satellite Gravity" -Fs4i/3.75i -A+jTR+o0.1i -BWeSn+g240/255/240 -X2i -Y1.5i gmt subplot set 0,0 -A"Input Power" - gmt plot spectrum.xpower -JX-?l/?l -Bxa1f3p -Bya1f3p+l"Power (mGal@+2@+km)" -Gred -ST0.07i -R1/1000/0.1/10000 -Ey+p0.5p - gmt plot spectrum.ypower -Gblue -Sc0.07i -Ey+p0.5p - gmt legend -DjBL+w1.2i+o0.25i -F+gwhite+pthicker --FONT_ANNOT_PRIMARY=14p,Helvetica-Bold <<- EOF - S 0.1i T 0.07i red - 0.3i Ship - S 0.1i c 0.07i blue - 0.3i Satellite - EOF + gmt plot spectrum.xpower -JX-?l/?l -Bxa1f3p -Bya1f3p+l"Power (mGal@+2@+km)" -Gred -ST0.07i -R1/1000/0.1/10000 -Ey+p0.5p -lShip + gmt plot spectrum.ypower -Gblue -Sc0.07i -Ey+p0.5p -lSatellite + gmt legend -DjBL+w1.2i+o0.25i -F+gwhite+pthicker --FONT_ANNOT_PRIMARY=14p,Helvetica-Bold gmt subplot set 1,0 -A"Coherency@+2@+" gmt plot spectrum.coh -JX-?l/? -Bxa1f3p -Bya0.25f0.05+l"Coherency@+2@+" -R1/1000/0/1 -Sc0.07i -Gpurple -Ey+p0.5p gmt subplot end diff --git a/doc/examples/ex07/ex07.ps b/doc/examples/ex07/ex07.ps index 18935c3d26b..879215168a0 100644 Binary files a/doc/examples/ex07/ex07.ps and b/doc/examples/ex07/ex07.ps differ diff --git a/doc/examples/ex07/ex07.sh b/doc/examples/ex07/ex07.sh index dd20892747a..0128dc7a485 100755 --- a/doc/examples/ex07/ex07.sh +++ b/doc/examples/ex07/ex07.sh @@ -7,12 +7,10 @@ gmt begin ex07 gmt coast -R-50/0/-10/20 -JM9i -Slightblue -GP26+r300+ftan+bdarkbrown -Dl -Wthinnest -B --FORMAT_GEO_MAP=dddF gmt plot @fz_07.txt -Wthinner,- - gmt plot @quakes_07.txt -h1 -Sci -i0,1,2+s0.01 -Gred -Wthinnest + gmt plot @quakes_07.txt -h1 -Sci -i0,1,2+s0.01 -Gred -Wthinnest -l"ISC Earthquakes"+s0.08i gmt plot @isochron_07.txt -Wthin,blue gmt plot @ridge_07.txt -Wthicker,orange - gmt legend -DjTR+w2.2i+o0.2i -F+pthick+ithinner+gwhite --FONT_ANNOT_PRIMARY=18p,Times-Italic <<- EOF - S 0.1i c 0.08i red thinnest 0.3i ISC Earthquakes - EOF + gmt legend -DjTR+w2i+o0.2i -F+pthick+ithinner+gwhite --FONT_ANNOT_PRIMARY=18p,Times-Italic gmt text -F+f30,Helvetica-Bold,white=thin <<- END -43 -5 SOUTH -43 -8 AMERICA diff --git a/doc/rst/source/common_SYN_OPTs.rst_ b/doc/rst/source/common_SYN_OPTs.rst_ index b8063573d65..9d31c816264 100644 --- a/doc/rst/source/common_SYN_OPTs.rst_ +++ b/doc/rst/source/common_SYN_OPTs.rst_ @@ -42,6 +42,8 @@ .. |SYN_OPT-j| replace:: **-j**\ :ref:`flags <-j_full>` +.. |SYN_OPT-l| replace:: **-l**\ :ref:`flags <-l_full>` + .. |SYN_OPT-n| replace:: **-n**\ :ref:`flags <-n_full>` .. |SYN_OPT-o| replace:: **-o**\ :ref:`flags <-ocols_full>` diff --git a/doc/rst/source/cookbook/options.rst b/doc/rst/source/cookbook/options.rst index 49afa72c9c0..90d41d568a9 100644 --- a/doc/rst/source/cookbook/options.rst +++ b/doc/rst/source/cookbook/options.rst @@ -2,7 +2,7 @@ Standardized command line options ================================= Most of the programs take many of the same arguments such as those related -to setting the data region, the map projection, etc. The 24 switches in +to setting the data region, the map projection, etc. The switches in Table :ref:`switches ` have the same meaning in all the programs (although some programs may not use all of them). These options will be described here as well as in the manual pages, as is vital that you understand how @@ -45,6 +45,8 @@ importance (some are used a lot more than others). +----------+--------------------------------------------------------------------+ | **-j** | Specify how spherical distances should be computed | +----------+--------------------------------------------------------------------+ +| **-l** | Add a legend entry for the symbol or line being plotted | ++----------+--------------------------------------------------------------------+ | **-n** | Specify grid interpolation settings | +----------+--------------------------------------------------------------------+ | **-o** | Specify which output columns to write | @@ -1023,6 +1025,42 @@ slightly different meaning. Now, the *n_recs* argument is taken to mean how many *bytes* should be skipped (on input) or padded with the space character (on output). +.. _option_-l: + +Setting automatic legend entries: The **-l** option +--------------------------------------------------- + +Map or plot legends are created by :doc:`legend` and normally this module +will read a *specfile* that outlines how the legend should look. You can +make very detailed and complicated legends by mixing a variety of items, +such as symbol, free text, colorbars, scales, images, and more. Yet, for +the vast majority of plots displaying symbols or lines a simple legend will suffice. +The **-l** option is used to automatically build the *specfile* as we plot +the various layers that will make up our illustration. Apart from setting +the label string that goes with the current symbol or line, you can select +from a series of modifiers that mirror the effect of control codes normally +added to the *specfile* by hand. For instance, a simple plot with two +symbols can obtain a legend by using this option and modifiers and is shown +in Figure :ref:`Auto Legend `:: + + gmt begin fruit + gmt plot -R0/7.2/3/7.2 -Jx2c @Table_5_11.txt -Sc0.35c -Glightgreen -Wfaint -lApples+h"LEGEND"+f16p+d + gmt plot @Table_5_11.txt -St0.35c -Gorange -B -BWStr -lOranges + gmt legend -DjTR+w3c+o0.25c -F+p1p+ggray95+s + gmt end show + +As the script shows, when no *specfile* is given to :doc:`legend` then we +look for the automatically generated on in the session directory. + +.. _auto_legend: + +.. figure:: /_images/GMT_autolegend.* + :width: 500 px + :align: center + + Each of the two :doc:`plot` commands use **-l** to add a symbol to the + auto legend; the first also sets a legend header of given size and draws a horizontal line. + .. _option_-i: Input columns selection: The **-i** option diff --git a/doc/rst/source/explain_-l.rst_ b/doc/rst/source/explain_-l.rst_ new file mode 100644 index 00000000000..d3400c83bf0 --- /dev/null +++ b/doc/rst/source/explain_-l.rst_ @@ -0,0 +1,2 @@ +**-l**\ [*label*]\ [**+d**\ *pen*][**+f**\ *font*][**+g**\ *gap*][**+h**\ *header*\ ][**+j**\ *just*][**+n**\ *cols*][**+s**\ *size*\ ][**+v**\ [*pen*]][**+w**\ *width*][**+x**\ *scale*\ ] :ref:`(more ...) <-l_full>` + Add a legend entry for the symbol or line being plotted. |Add_-l| diff --git a/doc/rst/source/explain_-l_full.rst_ b/doc/rst/source/explain_-l_full.rst_ new file mode 100644 index 00000000000..ccf4bcf33e9 --- /dev/null +++ b/doc/rst/source/explain_-l_full.rst_ @@ -0,0 +1,23 @@ +.. _-l_full: + +**-l**\ [*label*]\ [**+d**\ *pen*][**+f**\ *font*][**+g**\ *gap*][**+h**\ *header*\ ][**+j**\ *just*][**+n**\ *cols*][**+s**\ *size*\ ][**+v**\ [*pen*]][**+w**\ *width*][**+x**\ *scale*\ ] + [**beta version**] Add a map legend entry to the session legend information file for the + current plot. Optionally append a text *label* to describe the entry. + Several modifiers allow further changes to the legend (to be built + when :doc:`legend` is called): Use **+d** to draw a horizontal line before the + legend entry is placed [no line], use **+f** to set the font used for the legend header [:ref:`FONT_TITLE `], + use **+g** to add some vertical space [0], use **+h** to add a legend header [no header], + **+j** to set placement of the legend [TR], use **+n** to change the number of columns used to + set the following legend items [1], use **+s** to override the size of the + current symbol for the legend or set a length if plotting a line or contour [same as plotted], + use **+v** to start and **+v**\ *pen* to stop drawing vertical line from + previous to current horizontal line [no vertical line], use **+w** to set legend width [auto], + and use **+x**\ *scale* to resize all symbol and length sizes in the legend. Default pen is + given by :ref:`MAP_DEFAULT_PEN `. Note that **+h**, **+j**, **+w**, and **+x** + will only take effect if given on the very first **-l** option for a plot. The **+n** modifier, + if used on the first **-l** option, affects the legend width (unless set via **+w**); otherwise it + just subdivides the available width among the specified columns. + The automatic legend has a fixed white background with a solid black pen outline and offset 0.2 cm from the map frame. + The modifiers largely reflect legend codes described in :doc:`legend`, which provide more details and + customization. If **legend** is not called explicitly we will call it implicitly when finishing the plot + via :doc:`end`. diff --git a/doc/rst/source/gallery/ex03.rst b/doc/rst/source/gallery/ex03.rst index dbdfd772b59..d097208c3e6 100644 --- a/doc/rst/source/gallery/ex03.rst +++ b/doc/rst/source/gallery/ex03.rst @@ -6,8 +6,7 @@ In this example we will show how to use the GMT programs :doc:`fitcircle `, :doc:`project `, :doc:`sample1d `, :doc:`spectrum1d `, -:doc:`plot `, and -:doc:`text `. Suppose you have (lon, lat, +and :doc:`plot `. Suppose you have (lon, lat, gravity) along a satellite track in a file called ``sat.xyg``, and (lon, lat, gravity) along a ship track in a file called ``ship.xyg``. You want to make a cross-spectral analysis of these data. First, you will have to get the @@ -21,19 +20,11 @@ ranges are in the projected coordinate. The :doc:`gmtinfo ` utility will report the minimum and maximum values for multi-column ASCII tables. Use this information to select the range of the projected distance coordinate they have in -common. The script prompts you for that information after reporting the -values. We decide to make a file of equidistant sampling points spaced 1 -km apart from -1167 to +1169, and use the UNIX utility **awk** to -accomplish this step. We can then resample the projected data, and carry +common. The script computes the common range. We can then resample the projected data, and carry out the cross-spectral calculations, assuming that the ship is the input -and the satellite is the output data. There are several intermediate -steps that produce helpful plots showing the effect of the various -processing steps (``example_03[a-f].ps``), while the final plot ``example_03.ps`` shows the ship and sat power +and the satellite is the output data. The final plot ``example_03.ps`` shows the ship and sat power in one diagram and the coherency on another diagram, both on the same -page. Note the extended use of :doc:`text ` -and :doc:`plot ` to put labels and legends -directly on the plots. For that purpose we often use **-Jx**\ 1i and -specify positions in inches directly. Thus, the complete automated script reads: +page, with an auto-generated legend. Thus, the complete automated script reads: .. literalinclude:: /_verbatim/ex03.txt :language: bash diff --git a/doc/rst/source/gmt.rst b/doc/rst/source/gmt.rst index 48a22c6eab7..728a718c9bd 100644 --- a/doc/rst/source/gmt.rst +++ b/doc/rst/source/gmt.rst @@ -225,6 +225,8 @@ programs. No space between the option flag and the associated arguments. .. |Add_-j| unicode:: 0x20 .. just an invisible code .. include:: explain_distcalc_full.rst_ +.. include:: explain_-l_full.rst_ + .. include:: explain_-n_full.rst_ .. include:: explain_-ocols_full.rst_ diff --git a/doc/rst/source/legend.rst b/doc/rst/source/legend.rst index c4495ebb0ab..8f2ac784687 100644 --- a/doc/rst/source/legend.rst +++ b/doc/rst/source/legend.rst @@ -20,6 +20,8 @@ Synopsis [ |-F|\ *box* ] [ |-J|\ *parameters* ] [ |SYN_OPT-R| ] +[ |-S|\ *scale* ] +[ |-T|\ *file* ] [ |SYN_OPT-U| ] [ |SYN_OPT-V| ] [ |SYN_OPT-X| ] @@ -74,6 +76,18 @@ specifications, use:: T so we may have to adjust the box height to get the right size box. EOF +Auto-legends +------------ + +In modern mode, some modules can access the **-l** option and build the legend +*specfile* from individual entries per command. The **-l** option takes a +label and allows optional modifiers **+d**, **+g**, **+n**, **+h**, **+j**, and **+v** +that follows the corresponding uppercase legend codes discussed above. In addition, +there is **+f** to set current font and **+s** to set the symbol size (or line length) +to use for the current entry. Some defaults are hardwired: We draw a white panel with +a 1 point outline offset from the justification point (**+j**) by 0.2 cm. To use +different settings you must call **legend** explicitly instead. + See Also -------- diff --git a/doc/rst/source/legend_common.rst_ b/doc/rst/source/legend_common.rst_ index 49addeb2ed7..39b213edc4d 100644 --- a/doc/rst/source/legend_common.rst_ +++ b/doc/rst/source/legend_common.rst_ @@ -72,6 +72,16 @@ Optional Arguments .. |Add_-R| unicode:: 0x20 .. just an invisible code .. include:: explain_-R.rst_ +.. _-S: + +**-S**\ *scale* + Scale all symbol sizes by a common *scale* [1]. + +.. _-T: + +**-T**\ *file* + Modern mode only: Write hidden legend specification file to *file*. + .. _-U: .. include:: explain_-U.rst_ diff --git a/doc/rst/source/plot.rst b/doc/rst/source/plot.rst index 52901b50b0c..e57d67fe2b0 100644 --- a/doc/rst/source/plot.rst +++ b/doc/rst/source/plot.rst @@ -40,6 +40,7 @@ Synopsis [ |SYN_OPT-g| ] [ |SYN_OPT-h| ] [ |SYN_OPT-i| ] +[ |SYN_OPT-l| ] [ |SYN_OPT-p| ] [ |SYN_OPT-t| ] [ |SYN_OPT-:| ] diff --git a/doc/rst/source/plot_common.rst_ b/doc/rst/source/plot_common.rst_ index b0733f6e997..a6b5d7aa9b3 100644 --- a/doc/rst/source/plot_common.rst_ +++ b/doc/rst/source/plot_common.rst_ @@ -219,6 +219,9 @@ Optional Arguments .. include:: explain_-icols.rst_ +.. |Add_-l| unicode:: 0x20 .. just an invisible code +.. include:: explain_-l.rst_ + .. include:: explain_colon.rst_ .. |Add_perspective| unicode:: 0x20 .. just an invisible code diff --git a/doc/rst/source/std_opts.rst b/doc/rst/source/std_opts.rst index a662e8d287b..99f6e0c4360 100644 --- a/doc/rst/source/std_opts.rst +++ b/doc/rst/source/std_opts.rst @@ -2,63 +2,67 @@ Common Options ############## -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **STANDARDIZED COMMAND LINE OPTIONS** | -+====================================================================+==========================================================================+ -| **-B**\ *information* | Specify map frame and axes parameters :ref:`(...) <-B_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-J**\ *parameters* | Select map projection :ref:`(...) <-J_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-R**\ *west/east/south/north*\ [*/zmin/zmax*][**+r**] | Specify Region of interest :ref:`(...) <-R_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-U**\ [*label*][**+c**][**+j**\ *just*\ ][**+o**\ *dx*/*dy*\ ] | Plot time-stamp on plot :ref:`(...) <-U_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-V**\ [*verbosity*] | Run in verbose mode :ref:`(...) <-V_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-X**\ [**a**\ \|\ **c**\ \|\ **r**]\ *off*\ [**u**] | Shift plot origin in *x*-direction :ref:`(...) <-XY_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-Y**\ [**a**\ \|\ **c**\ \|\ **r**]\ *off*\ [**u**] | Shift plot origin in *y*-direction :ref:`(...) <-XY_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-a**\ *name=col,...* | Associates aspatial data with columns :ref:`(...) <-aspatial_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-bi**\ [*ncols*][*type*][**w**\ ][\ **+l**\ \|\ **b**] | Select binary input :ref:`(...) <-bi_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-bo**\ [*ncols*][*type*][**w**\ ][\ **+l**\ \|\ **b**] | Select binary output :ref:`(...) <-bo_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-c**\ [*row*\ ,\ *col*\ \|\ *index*\ ] | Advance plot focus to selected (or next) subplot panel | -| | :ref:`(...) <-c_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-d**\ [**i**\ \|\ **o**]\ *nodata* | Replace columns with *nodata* with NaN :ref:`(...) <-d_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-e**\ [**~**]\ *"pattern"* **\| -e**\ [**~**]/\ *regexp*/[**i**] | Filter data records that match the given pattern :ref:`(...) <-e_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-f**\ [**i**\ \|\ **o**]\ *colinfo* | Set formatting of ASCII input or output :ref:`(...) <-f_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-g**\ [**+**]\ **x**\ \|\ **X**\ \|\ **y**\ \|\ | | -| **Y**\ \|\ **d**\ \|\ **D**\ *gap*\ [**u**][**+n**\ \|\ **p**] | Segment data by detecting gaps :ref:`(...) <-g_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-h**\ [**i**\ \|\ **o**][*n\_headers*] | ASCII [*I*\ \|\ *O*] tables have header record[s] :ref:`(...) <-h_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-i**\ *columns* | Selection of input columns :ref:`(...) <-icols_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-je**\ \|\ **f**\ \|\ **g** | Mode of spherical distance calculation :ref:`(...) <-j_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-n**\ [*type*][**+a**][\ **+b**\ *BC*] | | -| [\ **+c**\ ][\ **+t**\ *threshold*] | Set grid interpolation mode :ref:`(...) <-n_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-o**\ *columns* | Selection of output columns :ref:`(...) <-ocols_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-p**\ *azim*\ [/*elev*\ [/*zlevel*]][\ **+w**\ *lon0/lat0*\ | | -| [/*z0*]][\ **+v**\ *x0/y0*] | Control 3-D perspective view :ref:`(...) ` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-r**\ [**g**\ \|\ **p**\ ] | Sets grid registration :ref:`(...) ` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-s**\ [*cols*\ ][\ **+a**\ \|\ **+r**] | Control treatment of NaN records :ref:`(...) <-s_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-t**\ *transparency* | Set layer transparency :ref:`(...) <-t_full>` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-x**\ [[-]\ *n*] | Set number of cores in multi-threaded modules :ref:`(...) ` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ -| **-:**\ [**i**\ \|\ **o**] | Expect *y*/*x* input rather than *x*/*y* :ref:`(...) ` | -+--------------------------------------------------------------------+--------------------------------------------------------------------------+ ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **STANDARDIZED COMMAND LINE OPTIONS** | ++==========================================================================+==========================================================================+ +| **-B**\ *information* | Specify map frame and axes parameters :ref:`(...) <-B_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-J**\ *parameters* | Select map projection :ref:`(...) <-J_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-R**\ *west/east/south/north*\ [*/zmin/zmax*][**+r**] | Specify Region of interest :ref:`(...) <-R_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-U**\ [*label*][**+c**][**+j**\ *just*\ ][**+o**\ *dx*/*dy*\ ] | Plot time-stamp on plot :ref:`(...) <-U_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-V**\ [*verbosity*] | Run in verbose mode :ref:`(...) <-V_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-X**\ [**a**\ \|\ **c**\ \|\ **r**]\ *off*\ [**u**] | Shift plot origin in *x*-direction :ref:`(...) <-XY_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-Y**\ [**a**\ \|\ **c**\ \|\ **r**]\ *off*\ [**u**] | Shift plot origin in *y*-direction :ref:`(...) <-XY_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-a**\ *name=col,...* | Associates aspatial data with columns :ref:`(...) <-aspatial_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-bi**\ [*ncols*][*type*][**w**\ ][\ **+l**\ \|\ **b**] | Select binary input :ref:`(...) <-bi_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-bo**\ [*ncols*][*type*][**w**\ ][\ **+l**\ \|\ **b**] | Select binary output :ref:`(...) <-bo_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-c**\ [*row*\ ,\ *col*\ \|\ *index*\ ] | Advance plot focus to selected (or next) subplot panel | +| | :ref:`(...) <-c_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-d**\ [**i**\ \|\ **o**]\ *nodata* | Replace columns with *nodata* with NaN :ref:`(...) <-d_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-e**\ [**~**]\ *"pattern"* **\| -e**\ [**~**]/\ *regexp*/[**i**] | Filter data records that match the given pattern :ref:`(...) <-e_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-f**\ [**i**\ \|\ **o**]\ *colinfo* | Set formatting of ASCII input or output :ref:`(...) <-f_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-g**\ [**+**]\ **x**\ \|\ **X**\ \|\ **y**\ \|\ | | +| **Y**\ \|\ **d**\ \|\ **D**\ *gap*\ [**u**][**+n**\ \|\ **p**] | Segment data by detecting gaps :ref:`(...) <-g_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-h**\ [**i**\ \|\ **o**][*n\_headers*] | ASCII [*I*\ \|\ *O*] tables have header record[s] :ref:`(...) <-h_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-i**\ *columns* | Selection of input columns :ref:`(...) <-icols_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-je**\ \|\ **f**\ \|\ **g** | Mode of spherical distance calculation :ref:`(...) <-j_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-l**\ [*label*]\ [**+d**\ *pen*][**+f**\ *font*][**+g**\ *gap*]\ | Add an item to the automatic plot legend :ref:`(...) <-l_full>` | +| [**+h**\ *header*\ ][**+j**\ *just*][**+n**\ *cols*]\ | | +| [**+s**\ *size*\ ][**+v**\ [*pen*]][**+w**\ *width*][**+x**\ *scale*\ ] | | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-n**\ [*type*][**+a**][\ **+b**\ *BC*] | | +| [\ **+c**\ ][\ **+t**\ *threshold*] | Set grid interpolation mode :ref:`(...) <-n_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-o**\ *columns* | Selection of output columns :ref:`(...) <-ocols_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-p**\ *azim*\ [/*elev*\ [/*zlevel*]][\ **+w**\ *lon0/lat0*\ | | +| [/*z0*]][\ **+v**\ *x0/y0*] | Control 3-D perspective view :ref:`(...) ` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-r**\ [**g**\ \|\ **p**\ ] | Sets grid registration :ref:`(...) ` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-s**\ [*cols*\ ][\ **+a**\ \|\ **+r**] | Control treatment of NaN records :ref:`(...) <-s_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-t**\ *transparency* | Set layer transparency :ref:`(...) <-t_full>` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-x**\ [[-]\ *n*] | Set number of cores in multi-threaded modules :ref:`(...) ` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ +| **-:**\ [**i**\ \|\ **o**] | Expect *y*/*x* input rather than *x*/*y* :ref:`(...) ` | ++--------------------------------------------------------------------------+--------------------------------------------------------------------------+ diff --git a/doc/scripts/CMakeLists.txt b/doc/scripts/CMakeLists.txt index 409057ff803..84fd5f8e851 100644 --- a/doc/scripts/CMakeLists.txt +++ b/doc/scripts/CMakeLists.txt @@ -52,7 +52,7 @@ set (_scr_other GMT_-B_geo_1.sh GMT_-B_geo_2.sh GMT_-B_linear.sh GMT_-B_log.sh GMT_API_flow.sh GMT_pstext_clearance.sh GMT_pstext_justify.sh GMT_registration.sh GMT_obl_nz.sh GMT_utm_zones.sh GMT_volcano.sh GMT_panel.sh GMT_mapscale.sh GMT_inset.sh GMT_linearrow.sh GMT_dir_rose.sh GMT_images.sh GMT_colorbar.sh GMT_cyclic.sh GMT_legend.sh GMT_mag_rose.sh - GMT_hinge.sh GMT_CPTscale.sh GMT_SRTM.sh GMT_vertscale.sh GMT_fatline.sh + GMT_hinge.sh GMT_CPTscale.sh GMT_SRTM.sh GMT_vertscale.sh GMT_fatline.sh GMT_autolegend.sh psevents_intensity.sh psevents_size.sh psevents_transparency.sh) # Scripts that are only used for testing, figures are not in the documentation diff --git a/doc/scripts/GMT_autolegend.ps b/doc/scripts/GMT_autolegend.ps new file mode 100644 index 00000000000..672f60486d2 Binary files /dev/null and b/doc/scripts/GMT_autolegend.ps differ diff --git a/doc/scripts/GMT_autolegend.sh b/doc/scripts/GMT_autolegend.sh new file mode 100755 index 00000000000..3d3883154f3 --- /dev/null +++ b/doc/scripts/GMT_autolegend.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +gmt begin GMT_autolegend + gmt plot -R0/7.2/3/7.2 -Jx2c @Table_5_11.txt -Sc0.35c -Glightgreen -Wfaint -lApples+h"LEGEND"+f16p+d + gmt plot @Table_5_11.txt -St0.35c -Gorange -B -BWStr -lOranges + gmt legend -DjTR+w3c+o0.25c -F+p1p+ggray95+s +gmt end show diff --git a/src/gmt_api.c b/src/gmt_api.c index bdd612b5604..a4e510be6f7 100644 --- a/src/gmt_api.c +++ b/src/gmt_api.c @@ -11010,7 +11010,7 @@ int GMT_Option (void *V_API, const char *options) { break; case 'd': /* Nodata flag -d, -di, -do */ if (p[1] == 'i') arg[k++] = 'k'; - else if (p[1] == 'o') arg[k++] = 'l'; + else if (p[1] == 'o') arg[k++] = 'm'; else arg[k++] = 'd'; break; case 'j': /* Spherical distance calculation mode */ diff --git a/src/gmt_common.h b/src/gmt_common.h index 1813f89531f..0884cae5d7f 100644 --- a/src/gmt_common.h +++ b/src/gmt_common.h @@ -54,6 +54,20 @@ enum GMT_enum_gaps {GMT_NEGGAP_IN_COL = 0, /* Check if previous minus current co #define GSET 2 /* Index into R.active[] for -r */ #define FSET 3 /* Index into R.active[] for "got -R -I -r from a grid file" */ +struct GMT_LEGEND_ITEM { /* Information about one item in a legend */ + char label[GMT_LEN128]; /* The label to go with the symbol */ + char header[GMT_LEN128]; /* Header for the whole legend */ + char font[GMT_LEN32]; /* Fontsize to use */ + char pen[2][GMT_LEN32]; /* Pens to use with +d and +v */ + int draw; /* 0 no draw, 1 draw horizontal +d, 2 draw vertical +v */ + int just; /* Legend placement [TR] */ + double size; /* Fixed symbol size when otherwise cannot set it */ + double scale; /* Scale all given sizes, including +s of a line */ + double width; /* Override auto-width with a fixed legend width */ + double gap; /* Move this much down before placing symbol entry */ + unsigned int ncols; /* How many columns to use for symbols */ +}; + /*! Structure with all information given via the common GMT command-line options -R -J .. */ struct GMT_COMMON { struct synopsis { /* \0 (zero) or ^ */ @@ -185,9 +199,9 @@ struct GMT_COMMON { enum GMT_enum_mdist mode; /* Defaults to GMT_GREATCIRCLE */ char string[GMT_LEN8]; } j; - struct l { /* -l