Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Graphs and selective legends


From   "Allan Reese (Cefas)" <allan.reese@cefas.co.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Graphs and selective legends
Date   Wed, 25 Aug 2010 11:43:32 +0100

ashokankur <ashokankur@gmail.com> posed the question "Remove legends for
few line graphs in a figure that has many".

The direct answer, already given, is to use legend( order( ... ) ... ).

Expanding on this, one of the strengths of Stata over point'n'click
software is the degree of control this implies.  A graph with many lines
can be a mess.  When used for presentation, you need to be clear about
the intended message.  For example, many lines overlapping may show a
common pattern with variability; or the lines may fall into distinct
clusters; or there may be a general pattern but one or more exceptions.
Stata has commands to group lines or separate them using combinations or
colour, pattern, width, tone, etc.  You can foreground or background
selected groups of lines or points.  The legend should reflect the
groups but also the visual ordering on the graph, as this will assist
the mental mapping of lines and meaning.  

A contrary example, drawn by another package and from a very influential
paper, is a stacked-bar chart where the software piles the bars from
bottom to top but lists the legend from top to bottom, and also piles
the segments in alphabetic order which was scientifically random. That
is graphical illiteracy - the authors just didn't see what they had
drawn.

It may seem rather pedestrian and not whizzy computing, but at least
with Stata you can list the options for each plotted line and tweak them
to make a graph that is literate.

Here's an example.  A response variable was separated into variables (d1
to d9) for each group and some groups were duplicate treatments.  Hence
the selective legend .  I generally prefer the legend within the
plotting area providing it's not obscuring any features.  This command
was the end point of an editing process based on seeing what needed
emphasising or de-emphasising to compare treatments with controls.  When
plotted, it seemed interesting that some treatments were above the
control and others below.  Some of the d1 values were "tweaked" from 29
to 28.8 so that lines were not exactly coincident and both patterns
could be seen.  Symbol sizes were also adjusted so coincident points
were visible.  scatter d? day, c(L L L L L L L L L)  msym(s sh sh dh dh
oh oh th th)  mcol( gs1 gs4 gs4 gs6 gs6 gs8 gs8 gs10 gs10)  msize(*.8
*.8 *.8  *.8 *.7   *1.2 *1   *.8 *.7 )   clpattern( l  l  l  _  _  -  -
_.  _. )   clcol( gs3 gs6 gs6 gs8 gs8 gs10 gs10 gs12 gs12)  clwidth( *1
*1 *1 *1 *1 *1.5 *1.5 *1.5 *1.5 )   legend( order(4 "treat 1"  6 "treat
2"  1 "pos control" 8 "treat 3"  2 "neg control" ) col(1) ring(0) pos(3)
size(*.75) rowgap(.5) )   ylab( 0(5)30, angle(0) )   xlab( 0 4 8 12 18)
yti(Cumulative response) xti(Days since start)  aspect(.5)
scheme(s1mono) 

Allan





***********************************************************************************
This email and any attachments are intended for the named recipient only.  Its unauthorised use, distribution, disclosure, storage or copying is not permitted.  If you have received it in error, please destroy all copies and notify the sender.  In messages of a non-business nature, the views and opinions expressed are the author's own and do not necessarily reflect those of the organisation from which it is sent.  All emails may be subject to monitoring.
***********************************************************************************


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index