123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <h2>DESCRIPTION</h2>
- <em>d.legend</em> displays a legend for a user-specified raster map or
- 3D raster map layer in the active frame on the graphics monitor.
- <p>
- The legend's default size is based on the dimensions of the
- active frame, specifically its height. <em>d.legend</em> will only
- obscure those portions of the active frame that directly underlie the legend.
- <h2>NOTES</h2>
- When using the <b>at</b> to size & place the legend, a user may
- create a horizontal legend by making the box wider than it is tall.
- <p>
- Raster maps based on floating point values will display smoothed, from greatest
- to smallest value, while categorical raster maps will display in order, from
- top to bottom. Horizontal legends will always be smoothed. If the box is defined
- with inverted y-values or an inverted <b>range</b>, the legend will automatically
- flip. If this is not the desired result, the <b>-f</b> flag may be used to flip
- it back.
- <p>
- If the user attempts to display a very long legend in a relatively short
- display frame, the legend may appear in unreadably small text, or even revert
- to a smooth gradient legend. Use the <b>lines</b>, <b>thin</b>, <b>use</b>, <b>range</b>,
- and/or <b>-n</b> options to reduce the number of categories to be displayed,
- or the <b>-s</b> flag to force a smooth gradient legend.
- <p>
- The <b>lines</b> option will display the first number of categories, as defined
- by <em>value</em>, contained in the raster map. When used with the <b>-n</b> flag,
- it takes on a new meaning: "up to category #". When used with both
- <b>thin</b> and the <b>-n</b> flag, its meaning becomes more obscure. When
- using <b>lines</b>, auto-scaled text similar to "4 of 16 categories" will be placed at
- the bottom of the legend.
- <p>
- The <b>thin</b> option sets the thinning factor. For raster maps with a 0th
- category, <b>thin=</b><em>10</em> gives cats [0,10,20,...]. For raster maps
- starting at category 1, <b>thin=</b><em>10</em> gives cats [1,11,21,...].
- <p>
- The <b>use</b> option lets the user create a legend made up of arbitrary category
- values. e.g. <b>use=</b><em>1000,100,10,0,-10,-100,-1000</em>
- <p>
- The <b>range</b> option lets the user define the minimum and maximum categories
- to be used in the legend. It may also be used to define the limits of a smooth
- gradient legend created from a raster containing floating point values. Note
- the color scale will remain faithful to the category values as defined with
- <em><a href="r.colors.html">r.colors</a></em>, and the <b>range</b> may be
- extended to the limits defined by the <em><a href="r.colors.html">r.colors</a></em>
- color map.
- <p>
- The flag <b>-n</b> is useful for categorial maps, as it suppresses the
- drawing of non-existing categories (otherwise the full range is shown).
- <p>
- Vertical legends produced with <em>d.legend</em> will place text labels to the
- right of the legend box, horizontal legends will place text below. This text
- will be auto-scaled to fit within the frame, reducing the size of the legend
- if necessary. Legends positioned with the <b>at</b> option
- will not auto-scale text, in order to provide more control to the user.
- Smaller text may be obtained in this case by reducing the height of the box
- or by using the <b>fontsize</b> option. The <b>-c</b> and <b>-v</b> flags may
- be used to suppress the display of category numbers and labels respectively,
- or used together to suppress all text of categorial raster maps.
- <p>
- The text produced from floating-point raster maps will automatically create
- output with a meaningful number of significant digits. For very small values,
- numbers will be expressed in scientific notation, e.g. "1.7e-9". Option
- <b>digits</b> can be used to determine how many digits after decimal point
- will be displayed.
- <p>
- When the <b>-d</b> flag is used to display a histogram distribution along
- side the smoothed gradient legend, note that the statistics are calculated
- on the <i>current computational region</i> settings set by <em>g.region</em>.
- The default <b>range</b> however covers the entire natural bounds of the input map.
- If the histogram appears empty, check your region settings.
- <p>
- If the raster map's <i>units</i> metadata has been set with the
- <em>r.support</em> module then it will be displayed along side the legend.
- <p>
- The option <b>title</b> will display the custom title at the top of the legend.
- In case of vertical legend the title is aligned to the left edge of legend, in case
- of horizontal legend the title is aligned to the center. <b>title_fontsize</b> can
- be used to set the size of legend title. By default the legend title font size is
- the same as labels font size.
- <p>
- There are different options to customize displayed labels. The <b>labelnum</b> set
- the number of labels which are displayed in regular intervals. The <b>label_values</b>
- will specify the values where the labels will be displayed. The <b>label_step</b> will
- display labels at values which are divisible by this value.
- <p>
- The flag <b>-t</b> will show ticks at labels.
- <p>
- The flag <b>-b</b> will show the background. Options <b>bgcolor</b> and <b>border_color</b> can be
- used to choose the color of border and background fill.
- <p>
- The flag <b>-l</b> will switch to logarithmic scale. In case this flag is used,
- the provided step in <b>label_step</b> is interpreted in the logarithmic space.
- <h2>EXAMPLE</h2>
- Displaying the legend along with a histogram (North Carolina Sample dataset):
- <div class="code"><pre>
- g.region raster=elevation -p
- d.rast elevation
- d.legend -d elevation
- </pre></div>
- <center>
- <img src="d_legend.png" alt="Elevation map with legend" border=1>
- </center>
- Displaying the legend with custom labels and background:
- <div class="code"><pre>
- g.region raster=elevation -p
- d.rast elevation
- d.legend raster=elevation -t label_step=20 label_values=108 title=Legend -b bgcolor=255:255:204 border_color=gray
- </pre></div>
- <center>
- <img src="d_legend_custom_labels_and_background.png" alt="Elevation map with custom legend" border=1>
- </center>
- Displaying the legend with logarithmic scale:
- <div class="code"><pre>
- g.region raster=elevation -p
- r.watershed -a elevation=elevation threshold=1000 accumulation=flowacc
- d.rast flowacc
- d.legend raster=flowacc -t -l label_step=1
- </pre></div>
- <center>
- <img src="d_legend_logarithmic.png" alt="Flow accumulation map with logarithmic legend" border=1>
- </center>
- <h2>SEE ALSO</h2>
- <em>
- <a href="d.barscale.html">d.barscale</a>,
- <a href="d.colortable.html">d.colortable</a>,
- <a href="d.font.html">d.font</a>,
- <a href="d.grid.html">d.grid</a>,
- <a href="d.rast.html">d.rast</a>,
- <a href="d.rast.leg.html">d.rast.leg</a>,
- <a href="d.text.html">d.text</a>,
- <a href="d.vect.thematic.html">d.vect.thematic</a>,
- <a href="r.reclass.html">r.reclass</a>,
- <a href="r.stats.html">r.stats</a>,
- <a href="r3.stats.html">r3.stats</a>
- </em>
- <h2>AUTHORS</h2>
- Bill Brown, U.S. Army Construction Engineering Research Laboratories
- <br>Late 2002: Rewrite of much of the code. Hamish Bowman,
- Otago University, New Zealand
- <br>Additional improvements from various authors
- <p>
- <i>Last changed: $Date$</i>
|