lamp_mac/
ligend.pro
NAME:
LEGEND
PURPOSE:
Create an annotation legend for a plot.
EXPLANATION:
This procedure makes a legend for a plot. The legend can contain
a mixture of symbols, linestyles, Hershey characters (vectorfont),
and filled polygons (usersym). A test procedure, legendtest.pro,
shows legend's capabilities. Placement of the legend is controlled
with keywords like /right, /top, and /center or by using a position
keyword for exact placement (position=[x,y]) or via mouse (/position).
CALLING SEQUENCE:
LEGEND [,items][,keyword options]
EXAMPLES:
The call:
legend,['Plus sign','Asterisk','Period'],psym=[1,2,3]
produces:
-----------------
| |
| + Plus sign |
| * Asterisk |
| . Period |
| |
-----------------
Each symbol is drawn with a plots command, so they look OK.
Other examples are given in optional output keywords.
lines = indgen(6) ; for line styles
items = 'linestyle '+strtrim(lines,2) ; annotations
legend,items,linestyle=lines ; vertical legend---upper left
items = ['Plus sign','Asterisk','Period']
sym = [1,2,3]
legend,items,psym=sym ; ditto except using symbols
legend,items,psym=sym,/horizontal ; horizontal format
legend,items,psym=sym,box=0 ; sans border
legend,items,psym=sym,delimiter='=' ; embed '=' betw psym & text
legend,items,psym=sym,margin=2 ; 2-character margin
legend,items,psym=sym,position=[x,y] ; upper left in data coords
legend,items,psym=sym,pos=[x,y],/norm ; upper left in normal coords
legend,items,psym=sym,pos=[x,y],/device ; upper left in device coords
legend,items,psym=sym,/position ; interactive position
legend,items,psym=sym,/right ; at upper right
legend,items,psym=sym,/bottom ; at lower left
legend,items,psym=sym,/center ; approximately near center
legend,items,psym=sym,number=2 ; plot two symbols, not one
legend,items,/fill,psym=[8,8,8],colors=[10,20,30]; 3 filled squares
INPUTS:
items = text for the items in the legend, a string array.
For example, items = ['diamond','asterisk','square'].
You can omit items if you don't want any text labels.
OPTIONAL INPUT KEYWORDS:
linestyle = array of linestyle numbers If linestyle[i] < 0, then omit
ith symbol or line to allow a multi-line entry. If
linestyle = -99 then text will be left-justified.
psym = array of plot symbol numbers. If psym[i] is negative, then a
line connects pts for ith item. If psym[i] = 8, then the
procedure usersym is called with vertices define in the
keyword usersym. If psym[i] = 88, then use the previously
defined user symbol
vectorfont = vector-drawn characters for the sym/line column, e.g.,
['!9B!3','!9C!3','!9D!3'] produces an open square, a checkmark,
and a partial derivative, which might have accompanying items
['BOX','CHECK','PARTIAL DERIVATIVE'].
There is no check that !p.font is set properly, e.g., -1 for
X and 0 for PostScript. This can produce an error, e.g., use
!20 with PostScript and !p.font=0, but allows use of Hershey
*AND* PostScript fonts together.
N. B.: Choose any of linestyle, psym, and/or vectorfont. If none is
present, only the text is output. If more than one
is present, all need the same number of elements, and normal
plot behaviour occurs.
By default, if psym is positive, you get one point so there is
no connecting line. If vectorfont[i] = '',
then plots is called to make a symbol or a line, but if
vectorfont[i] is a non-null string, then xyouts is called.
/help = flag to print header
/horizontal = flag to make the legend horizontal
/vertical = flag to make the legend vertical (D=vertical)
box = flag to include/omit box around the legend (D=include)
outline_color = color of box outline (D = !P.color)
clear = flag to clear the box area before drawing the legend
delimiter = embedded character(s) between symbol and text (D=none)
colors = array of colors for plot symbols/lines (D=!P.color)
textcolors = array of colors for text (D=!P.color)
margin = margin around text measured in characters and lines
spacing = line spacing (D=bit more than character height)
pspacing = psym spacing (D=3 characters) (when number of symbols is
greater than 1)
charsize = just like !p.charsize for plot labels
charthick = just like !p.charthick for plot labels
thick = array of line thickness numbers (D = !P.thick), if used, then
linestyle must also be specified
position = data coordinates of the /top (D) /left (D) of the legend
normal = use normal coordinates for position, not data
device = use device coordinates for position, not data
number = number of plot symbols to plot or length of line (D=1)
usersym = 2-D array of vertices, cf. usersym in IDL manual.
(/USERSYM =square, default is to use existing USERSYM definition)
/fill = flag to fill the usersym
/left_legend = flag to place legend snug against left side of plot
window (D)
/right_legend = flag to place legend snug against right side of plot
window. If /right,pos=[x,y], then x is position of RHS and
text runs right-to-left.
/top_legend = flag to place legend snug against top of plot window (D)
/bottom = flag to place legend snug against bottom of plot window
/top,pos=[x,y] and /bottom,pos=[x,y] produce same positions.
If LINESTYLE, PSYM, VECTORFONT, THICK, COLORS, or TEXTCOLORS are
supplied as scalars, then the scalar value is set for every line or
symbol in the legend.
Outputs:
legend to current plot device
OPTIONAL OUTPUT KEYWORDS:
corners = 4-element array, like !p.position, of the normalized
coords for the box (even if box=0): [llx,lly,urx,ury].
Useful for multi-column or multi-line legends, for example,
to make a 2-column legend, you might do the following:
c1_items = ['diamond','asterisk','square']
c1_psym = [4,2,6]
c2_items = ['solid','dashed','dotted']
c2_line = [0,2,1]
legend,c1_items,psym=c1_psym,corners=c1,box=0
legend,c2_items,line=c2_line,corners=c2,box=0,pos=[c1[2],c1[3]]
c = [c1[0]
top ligend
ligend, items, BOTTOM_LEGEND=BOTTOM_LEGEND, BOX=BOX, CENTER_LEGEND=CENTER_LEGEND, CHARTHICK=CHARTHICK, CHARSIZE=CHARSIZE, CLEAR=CLEAR, COLORS=COLORS, CORNERS=CORNERS, DATA=DATA, DELIMITER=DELIMITER, DEVICE=DEVICE, FILL=FILL, HELP=HELP, HORIZONTAL=HORIZONTAL, LEFT_LEGEND=LEFT_LEGEND, LINESTYLE=LINESTYLE, MARGIN=MARGIN, NORMAL=NORMAL, NUMBER=NUMBER, POSITION=POSITION, PSPACING=PSPACING, PSYM=PSYM, RIGHT_LEGEND=RIGHT_LEGEND, SPACING=SPACING, SYMSIZE=SYMSIZE, TEXTCOLORS=TEXTCOLORS, THICK=THICK, TOP_LEGEND=TOP_LEGEND, USERSYM=USERSYM, VECTORFONT=VECTORFONT, VERTICAL=VERTICAL, OUTLINE_COLOR=OUTLINE_COLOR
** ****** ** User callable ** make legend in direct graphics =====>> HELP
Parameters
- items
Keywords
- BOTTOM_LEGEND
- BOX
- CENTER_LEGEND
- CHARTHICK
- CHARSIZE
- CLEAR
- COLORS
- CORNERS
- DATA
- DELIMITER
- DEVICE
- FILL
- HELP
- HORIZONTAL
- LEFT_LEGEND
- LINESTYLE
- MARGIN
- NORMAL
- NUMBER
- POSITION
- PSPACING
- PSYM
- RIGHT_LEGEND
- SPACING
- SYMSIZE
- TEXTCOLORS
- THICK
- TOP_LEGEND
- USERSYM
- VECTORFONT
- VERTICAL
- OUTLINE_COLOR
File attributes
Modification date: | Tue Oct 1 14:36:01 2013 |
Lines: | 472 |