.\
cglegend.pro
top cgLegend
Graphics
cgLegend [, /ADDCMD] [, ALIGNMENT=integer] [, /BACKGROUND] [, BG_COLOR=string] [, /BOX] [, BX_COLOR=varies] [, BX_THICK=float] [, /CENTER_SYM] [, CHARSIZE=float] [, CHARTHICK=float] [, COLORS=varies] [, /DATA] [, /HARDWARE] [, LENGTH=float] [, LINESTYLES=integer] [, LOCATION=fltarr] [, PSYMS=integer] [, SYMCOLORS=varies] [, SYMSIZE=float] [, SYMTHICK=float] [, TCOLORS=varies] [, THICK=float] [, TITLES=string/strarr] [, TT_FONT=string] [, /VISIBLE] [, VSPACE=float] [, /WINDOW]
The purpose of this program is to a create simple legend that can be drawn in a graphics window. Users needing more complex legends may prefer to use AL_Legend from the NASA Astronomy IDL Library. This program has a more limited set of functionality, especially in regard to placement options. This program is a wrapper for the cgLegendItem object.
Keywords
- ADDCMD in optional type=boolean default=0
If this keyword is set, the object is added to the resizeable graphics window, cgWindow. The DRAW method of the object is called in cgWindow.
- 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 out optional type=boolean default=0
Set this keyword to draw a colored background for the legend.
- BG_COLOR out 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. The default is to draw a symbol at each endpoint 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=varies default=black
The name of the data color. This is the color of each data line. May be an array.
- 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
The line style for drawing each line. May be an array.
- LOCATION in optional type=fltarr
A two-element vector giving the X and Y location of upper-left corner of the legend (or legend box, if the
Box
keyword is set) in normalized coordinates. If theData
keyword is set, the locations are taken to be in data coordinate space.- PSYMS in optional type=integer
Any normal IDL PSYM values, plus any value supported by the Coyote Library routine cgSYMCAT. An integer between 0 and 46. May be an array.
- SYMCOLORS in optional type=varies
The name of the symbol color. By default, the same as the
COLOR
keyword. May be an array.- SYMSIZE in optional type=float default=1.0
The symbol size.
- SYMTHICK in optional type=float
The thickness of the symbol. If not set, use !P.Thick at drawing time.
- TCOLORS in optional type=varies default=black
The
Title
color. May be an array.- THICK in optional type=float
The thickness of the line. If not set, use !P.Thick at drawing time.
- 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 if the legend should be drawn (visible=1), or if the legend 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.- WINDOW in optional type=boolean default=0
If this keyword is set, the object replaces any commands in a current cgWindow or it opens a new cgWindow and adds itself to it.
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'
cgLegend, SymColors=['red7', 'blu7'], PSyms=[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'
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
cgLegend, SymColors=['red7', 'blu7'], PSyms=[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 information
- 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
- Copyright:
Copyright (c) 2013, Fanning Software Consulting, Inc.
- History:
Change History:
Written 5 Dec 2013. David W Fanning. Added CharThick keyword. 1 Sept 2014. DWF.
File attributes
Modification date: | Fri Mar 27 11:07:35 2015 |
Lines: | 234 |
Docformat: | rst rst |