# coyote: CGLEGENDITEM__DEFINE

- coyote/Graphics
- [Source code]

Description

      The purpose of this program is to create a simple legend object that can be drawn on
      a data plot. The user can include any number of legend "items" in the final legend.

Categories

      Graphics

Examples

      A plot with a simple legend::
          cgDisplay, 800, 450
          cgPlot, cgDemoData(17), PSym=-6, SymColor='red7', Position=[0.15, 0.15, 0.7, 0.9]
          cgOPlot, cgDemoData(17), PSym=-15, SymColor='blu7'
          legendObj = Obj_New('cgLegendItem', SymColor=['red7', 'blu7'], $
              PSym=[6,15], Symsize=1.5, Location=[0.725, 0.9], Titles=['May 27', 'June 27'], $
              Length=0.075, /Box, VSpace=2.75, /Background, BG_Color='rose', /Draw)
          Obj_Destroy, legendObj
      Same as the previous example, but in a resizeable graphics window::
          cgWindow, WXSize=800, WYSize=450
          cgPlot, cgDemoData(17), PSym=-6, SymColor='red7', Position=[0.15, 0.15, 0.7, 0.9], /AddCmd
          cgOPlot, cgDemoData(17), PSym=-15, SymColor='blu7', /AddCmd
          legendObj = Obj_New('cgLegendItem', SymColor=['red7', 'blu7'], $
              PSym=[6,15], Symsize=1.5, Location=[0.725, 0.9], Titles=['May 27', 'June 27'], $
              Length=0.075, /Box, VSpace=2.75, /Background, BG_Color='rose', /AddCmd)

Author

      FANNING SOFTWARE CONSULTING::
         David W. Fanning
         1645 Sheely Drive
         Fort Collins, CO 80526 USA
         Phone: 970-221-0438
         E-mail: david@idlcoyote.com
         Coyote's Guide to IDL Programming: http://www.idlcoyote.com

History

      Change History::
         Written 18 July 2012. DWF.
         Adapted to accept multiple legend elements. Legend elements are stacked vertically.
            Each legend element can be given its own title, color, symbol symbol color, and
            linestyle. Legend elements are offset  by 1.3*!D.Y_CH_Size/!D.YSize.  A single
            symbol can now be drawn in the center of the line instead of one at each end
            point with the CENTER_SYM keyword. 04/25/2013, Matthew Argall.
         Many changes to make this work like a simple, but useful, legend-drawing program. Now
            called by the wrapper cgLegend. 5 Dec 2013. DWF.
         Several small problems with pointers in the SetProperty method fixed. 10 June 2014. DWF.
         Added CharThick keyword. 1 Sept 2014. DWF.

Copyright

      Copyright (c) 2013, Fanning Software Consulting, Inc.
       is the initialization method for the object. It creates an instance of
      object.

Keywords

      alignment: in, optional, type=integer, default=0
         This keyword affects the alignment of the legend box with respect to the `Location` point.
         There are nine possible values (0 to 8) that assign the location point to be one of the
         four corners of the legend box, or the middle of one of the four sides of the legend box.
         The values are specified as follows::
            0 - Location specifies the upper left corner of the legend box.
            1 - Location specifies the upper right corner of the legend box.
            2 - Location specifies the lower right corner of the legend box.
            3 - Location specifies the lower left corner of the legend box.
            4 - Location specifies the top side of the legend box (centered horizontally).
            5 - Location specifies the bottom side of the legend box (centered horizontally).
            6 - Location specifies the left side of the legend box (centered vertically).
            7 - Location specifies the right side of the legend box (centered vertically).
            8 - Location specified the very center of the legend box.
      background: in, optional, type=boolean, default=0
         Set this keyword to draw a colored background for the legend.
      bg_color: in, optional, type=string, default="white"
         The name of the background color.
      box: in, optional, type=boolean, default=0
         Set this keyword to draw a box around the legend items.
      bx_color: in, optional, type=varies, default="black"
         The color of the box drawn around the legend items.
      bx_thick: in, optional, type=float
         The thickness of the line used to draw the box around the legend items.
         If not set, use !P.Thick at drawing time.
      center_sym: in, optional, type=boolean
         Set this keyword to place a single symbol in the center of the line.
      charsize: in, optional, type=float
         The character size for the legend text. Uses cgDefCharsize by default.
         Ignored if using hardware fonts on the display.
      charthick: in, optional, type=float
         The thickness of the legend text. If undefined, use `Thick` value.
      colors: in, optional, type=string/strarr
         The name of the data color. This is the color of each data line.
      data: in, optional, type=boolean, default=0
         If set the values specified by the `Location` keyword are taken to be in data
         coordinate space.
      hardware: in, optional, type=boolean
         Set this keyword if you want to output the legend text in a hardware font.
      length: in, optional, type=float, default=0.075
         The length of the line connecting symbols in the legend, in normalized
         coordinates (0 to 1 in the graphics window). Set this equal to 0.0 if
         you wish to only plot symbols in the legend.
      linestyles: in, optional, type=integer/intarr
         The line style for drawing each line.
      location: in, optional, type=fltarr
         The location of the upper-left corner of the legend item,
         in normalized coordinates (0 to 1 in the graphics window).
         The default is [0.1, 0.95].
      psyms: in, optional, type=integer/intarr
         Any normal IDL PSYM values, plus any value supported by the Coyote Library
         routine cgSYMCAT. An integer between 0 and 46.
      symcolors: in, optional, type=string/strarr
         The name of the symbol color. By default, the same as the `COLOR` keyword.
      symsize: in, optional, type=float, default=1.0
         The symbol size.
      symthick: in, optional, type=float, default=1.0
         The thickness of the symbol.
      tcolors: in, optional, type=string/strarr
         The `Titles` color. Set by default to `Color`.
      thick: in, optional, type=float, default=1.0
         The thickness of the line.
      titles: in, optional, type=string/strarr, default='Plot Item'
         The "title" or text for each legend item.
      tt_font: in, optional, type=string
         The name of a true-type font to use for the legend text.
      visible: in, optional, type=boolean, default=1
         Set this keyword to determine in the line should be drawn (visible=1), or
         if the line should not be drawn (visible=0).
      vspace: in, optional, type=float, default=1.5
         A scale factor for vertical spacing between legend items. This number is multiplied by
         `Charsize` to determine vertical spacing.
      x_margin: in, optional, type=float, default=2.25
         A scale factor for the horizontal margin within a box. This number is multiplied by
         `Charsize` to determine horizontal spacing.
      y_margin: in, optional, type=float, default=1.75
         A scale factor for the vertical margin within a box. This number is multiplied by
         `Charsize` to determine vertical spacing.
       method destroys anything the object uses that retains memory space.
      class definition module for the object.

Params

      class: out, optional, type=struct
         The class definition as a structure variable. Occasionally useful.