d.legend.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <h2>DESCRIPTION</h2>
  2. <em>d.legend</em> displays a legend for a user-specified raster map or
  3. 3D raster map layer in the active frame on the graphics monitor.
  4. <p>
  5. The legend's default size is based on the dimensions of the
  6. active frame, specifically its height. <em>d.legend</em> will only
  7. obscure those portions of the active frame that directly underlie the legend.
  8. <h2>NOTES</h2>
  9. When using the <b>at</b> to size &amp; place the legend, a user may
  10. create a horizontal legend by making the box wider than it is tall.
  11. <p>
  12. Raster maps based on floating point values will display smoothed, from greatest
  13. to smallest value, while categorical raster maps will display in order, from
  14. top to bottom. Horizontal legends will always be smoothed. If the box is defined
  15. with inverted y-values or an inverted <b>range</b>, the legend will automatically
  16. flip. If this is not the desired result, the <b>-f</b> flag may be used to flip
  17. it back.
  18. <p>
  19. If the user attempts to display a very long legend in a relatively short
  20. display frame, the legend may appear in unreadably small text, or even revert
  21. to a smooth gradient legend. Use the <b>lines</b>, <b>thin</b>, <b>use</b>, <b>range</b>,
  22. and/or <b>-n</b> options to reduce the number of categories to be displayed,
  23. or the <b>-s</b> flag to force a smooth gradient legend.
  24. <p>
  25. The <b>lines</b> option will display the first number of categories, as defined
  26. by <em>value</em>, contained in the raster map. When used with the <b>-n</b> flag,
  27. it takes on a new meaning: "up to category #". When used with both
  28. <b>thin</b> and the <b>-n</b> flag, its meaning becomes more obscure. When
  29. using <b>lines</b>, auto-scaled text similar to "4 of 16 categories" will be placed at
  30. the bottom of the legend.
  31. <p>
  32. The <b>thin</b> option sets the thinning factor. For raster maps with a 0th
  33. category, <b>thin=</b><em>10</em> gives cats [0,10,20,...]. For raster maps
  34. starting at category 1, <b>thin=</b><em>10</em> gives cats [1,11,21,...].
  35. <p>
  36. The <b>use</b> option lets the user create a legend made up of arbitrary category
  37. values. e.g.&nbsp;<b>use=</b><em>1000,100,10,0,-10,-100,-1000</em>
  38. <p>
  39. The <b>range</b> option lets the user define the minimum and maximum categories
  40. to be used in the legend. It may also be used to define the limits of a smooth
  41. gradient legend created from a raster containing floating point values. Note
  42. the color scale will remain faithful to the category values as defined with
  43. <em><a href="r.colors.html">r.colors</a></em>, and the <b>range</b> may be
  44. extended to the limits defined by the <em><a href="r.colors.html">r.colors</a></em>
  45. color map.
  46. <p>
  47. The flag <b>-n</b> is useful for categorial maps, as it suppresses the
  48. drawing of non-existing categories (otherwise the full range is shown).
  49. <p>
  50. Vertical legends produced with <em>d.legend</em> will place text labels to the
  51. right of the legend box, horizontal legends will place text below. This text
  52. will be auto-scaled to fit within the frame, reducing the size of the legend
  53. if necessary. Legends positioned with the <b>at</b> option
  54. will not auto-scale text, in order to provide more control to the user.
  55. Smaller text may be obtained in this case by reducing the height of the box
  56. or by using the <b>fontsize</b> option. The <b>-c</b> and <b>-v</b> flags may
  57. be used to suppress the display of category numbers and labels respectively,
  58. or used together to suppress all text of categorial raster maps.
  59. <p>
  60. The text produced from floating-point raster maps will automatically create
  61. output with a meaningful number of significant digits. For very small values,
  62. numbers will be expressed in scientific notation, e.g.&nbsp;"1.7e-9". Option
  63. <b>digits</b> can be used to determine how many digits after decimal point
  64. will be displayed.
  65. <p>
  66. When the <b>-d</b> flag is used to display a histogram distribution along
  67. side the smoothed gradient legend, note that the statistics are calculated
  68. on the <i>current computational region</i> settings set by <em>g.region</em>.
  69. The default <b>range</b> however covers the entire natural bounds of the input map.
  70. If the histogram appears empty, check your region settings.
  71. <p>
  72. If the raster map's <i>units</i> metadata has been set with the
  73. <em>r.support</em> module then it will be displayed along side the legend.
  74. <p>
  75. The option <b>title</b> will display the custom title at the top of the legend.
  76. In case of vertical legend the title is aligned to the left edge of legend, in case
  77. of horizontal legend the title is aligned to the center. <b>title_fontsize</b> can
  78. be used to set the size of legend title. By default the legend title font size is
  79. the same as labels font size.
  80. <p>
  81. There are different options to customize displayed labels. The <b>labelnum</b> set
  82. the number of labels which are displayed in regular intervals. The <b>label_values</b>
  83. will specify the values where the labels will be displayed. The <b>label_step</b> will
  84. display labels at values which are divisible by this value.
  85. <p>
  86. The flag <b>-t</b> will show ticks at labels.
  87. <p>
  88. The flag <b>-b</b> will show the background. Options <b>bgcolor</b> and <b>border_color</b> can be
  89. used to choose the color of border and background fill.
  90. <p>
  91. The flag <b>-l</b> will switch to logarithmic scale. In case this flag is used,
  92. the provided step in <b>label_step</b> is interpreted in the logarithmic space.
  93. <h2>EXAMPLE</h2>
  94. Displaying the legend along with a histogram (North Carolina Sample dataset):
  95. <div class="code"><pre>
  96. g.region raster=elevation -p
  97. d.rast elevation
  98. d.legend -d elevation
  99. </pre></div>
  100. <center>
  101. <img src="d_legend.png" alt="Elevation map with legend" border=1>
  102. </center>
  103. Displaying the legend with custom labels and background:
  104. <div class="code"><pre>
  105. g.region raster=elevation -p
  106. d.rast elevation
  107. d.legend raster=elevation -t label_step=20 label_values=108 title=Legend -b bgcolor=255:255:204 border_color=gray
  108. </pre></div>
  109. <center>
  110. <img src="d_legend_custom_labels_and_background.png" alt="Elevation map with custom legend" border=1>
  111. </center>
  112. Displaying the legend with logarithmic scale:
  113. <div class="code"><pre>
  114. g.region raster=elevation -p
  115. r.watershed -a elevation=elevation threshold=1000 accumulation=flowacc
  116. d.rast flowacc
  117. d.legend raster=flowacc -t -l label_step=1
  118. </pre></div>
  119. <center>
  120. <img src="d_legend_logarithmic.png" alt="Flow accumulation map with logarithmic legend" border=1>
  121. </center>
  122. <h2>SEE ALSO</h2>
  123. <em>
  124. <a href="d.barscale.html">d.barscale</a>,
  125. <a href="d.colortable.html">d.colortable</a>,
  126. <a href="d.font.html">d.font</a>,
  127. <a href="d.grid.html">d.grid</a>,
  128. <a href="d.rast.html">d.rast</a>,
  129. <a href="d.rast.leg.html">d.rast.leg</a>,
  130. <a href="d.text.html">d.text</a>,
  131. <a href="d.vect.thematic.html">d.vect.thematic</a>,
  132. <a href="r.reclass.html">r.reclass</a>,
  133. <a href="r.stats.html">r.stats</a>,
  134. <a href="r3.stats.html">r3.stats</a>
  135. </em>
  136. <h2>AUTHORS</h2>
  137. Bill Brown, U.S. Army Construction Engineering Research Laboratories
  138. <br>Late 2002: Rewrite of much of the code. Hamish Bowman,
  139. Otago University, New Zealand
  140. <br>Additional improvements from various authors
  141. <p>
  142. <i>Last changed: $Date$</i>