Documentation for pp_lib

Generated by IDLdoc

single page | use frames     summary     class     fields     routine details     file attributes

./

al_legend_pp.pro


Routines

top source al_legend_pp

al_legend_pp, 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, FONT=FONT, background_color=background_color

AL_LEGEND, from idlastro, with an extra keyword (background_color), to specifiy what color will fill the legend box when the keywrod clear is set. Create an annotation legend for a plot. Because IDL 8.0 contains a LEGEND() function written in IDL, the original LEGEND procedure in the Astronomy Library is renamed to AL_LEGEND. (The original legend.pro remains.) 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).

none

If keyword help is set, call doc_library to print header. See notes in the code. Much of the code deals with placement of the legend. The main problem with placement is not being able to sense the length of a string before it is output. Some crude approximations are used for centering.

Here are some things that aren't implemented. - An orientation keyword would allow lines at angles in the legend. - An array of usersyms would be nice---simple change. - An order option to interchange symbols and text might be nice. - Somebody might like double boxes, e.g., with box = 2. - Another feature might be a continuous bar with ticks and text. - There are no guards to avoid writing outside the plot area. - There is no provision for multi-line text, e.g., '1st line!c2nd line' Sensing !c would be easy, but !c isn't implemented for PostScript. A better way might be to simply output the 2nd line as another item but without any accompanying symbol or linestyle. A flag to omit the symbol and linestyle is linestyle[i] = -1. - There is no ability to make a title line containing any of titles for the legend, for the symbols, or for the text.

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
FONT
background_color

Examples

The call: al_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] al_legend,items,psym=sym ; ditto except using symbols al_legend,items,psym=sym,/horizontal ; horizontal format al_legend,items,psym=sym,box=0 ; sans border al_legend,items,psym=sym,delimiter='=' ; embed '=' betw psym & text al_legend,items,psym=sym,margin=2 ; 2-character margin al_legend,items,psym=sym,position=[x,y] ; upper left in data coords al_legend,items,psym=sym,pos=[x,y],/norm ; upper left in normal coords al_legend,items,psym=sym,pos=[x,y],/device ; upper left in device coords al_legend,items,psym=sym,/position ; interactive position al_legend,items,psym=sym,/right ; at upper right al_legend,items,psym=sym,/bottom ; at lower left al_legenditems,psym=sym,/center ; approximately near center al_legend,items,psym=sym,number=2 ; plot two symbols, not one al_legend,items,/fill,psym=[8,8,8],colors=[10,20,30]; 3 filled squares

Author information

History:

write, 24-25 Aug 92, F K Knight (knight@ll.mit.edu) allow omission of items or omission of both psym and linestyle, add corners keyword to facilitate multi-column legends, improve place- ment of symbols and text, add guards for unequal size, 26 Aug 92, FKK add linestyle(i)=-1 to suppress a single symbol/line, 27 Aug 92, FKK add keyword vectorfont to allow characters in the sym/line column, 28 Aug 92, FKK add /top, /bottom, /left, /right keywords for automatic placement at the four corners of the plot window. The /right keyword forces right-to-left printing of menu. 18 Jun 93, FKK change default position to data coords and add normal, data, and device keywords, 17 Jan 94, FKK add /center keyword for positioning, but it is not precise because text string lengths cannot be known in advance, 17 Jan 94, FKK add interactive positioning with /position keyword, 17 Jan 94, FKK allow a legend with just text, no plotting symbols. This helps in simply describing a plot or writing assumptions done, 4 Feb 94, FKK added thick, symsize, and clear keyword Feb 96, W. Landsman HSTX David Seed, HR Wallingford, d.seed@hrwallingford.co.uk allow scalar specification of keywords, Mar 96, W. Landsman HSTX added charthick keyword, June 96, W. Landsman HSTX Made keyword names left,right,top,bottom,center longer, Aug 16, 2000, Kim Tolbert Added ability to have regular text lines in addition to plot legend lines in legend. If linestyle is -99 that item is left-justified. Previously, only option for no sym/line was linestyle=-1, but then text was lined up after sym/line column. 10 Oct 2000, Kim Tolbert Make default value of thick = !P.thick W. Landsman Jan. 2001 Don't overwrite existing USERSYM definition W. Landsman Mar. 2002 Added outline_color BT 24 MAY 2004 Pass font keyword to xyouts commands. M. Fitzgerald, Sep. 2005 Default spacing, pspacing should be relative to charsize. M. Perrin, July 2007 Don't modify position keyword A. Kimball/ W. Landsman Jul 2007 Small update to Jul 2007 for /NORMAL coords. W. Landsman Aug 2007 Use SYMCAT() plotting symbols for 11<=PSYM<=46 W. Landsman Nov 2009 Make a sharper box edge T. Robishaw/W.Landsman July 2010 Added background_color keyword. Paulo Penteado (pp.penteado@gmail.com), Sep/2010

Statistics

Lines:
217 lines
Cyclomatic complexity:
106
Modified cyclomatic complexity:
87

File attributes

Modification date: Wed Jun 29 22:15:28 2016
Lines: 217
Docformat: idl preformatted