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]

Re: st: Labeling series within the plot area


From   Max.Livingston@ny.frb.org
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Labeling series within the plot area
Date   Tue, 4 Dec 2012 13:41:38 -0500

Thanks to all. Right now I'm simply setting local x and y variables equal 
to coordinates where there is whitespace in the graph, and then using 
-text(`y' `x' "Label")-, which is working OK, although it needs to be 
changed for every graph. Would be nice to have a more automated procedure, 
but you can't win 'em all.

Thanks again,
Max


Max Livingston
Research Analyst
Microeconomic Studies
Research and Statistics Group
Federal Reserve Bank of New York
(212) 720-7894



From:   Nick Cox <njcoxstata@gmail.com>
To:     statalist@hsphsun2.harvard.edu, 
Date:   11/30/2012 08:15 AM
Subject:        Re: st: Labeling series within the plot area
Sent by:        owner-statalist@hsphsun2.harvard.edu



Allan's nice suggestion is similar in spirit to my earlier posting.
With a little more work you can classify the data points and colour
groups consistently, e.g.

sysuse auto, clear
mark touse
markout touse price wei
regress price wei i.for#c.wei
predict yhat
separate yhat, by(foreign)
bysort touse foreign (weight):  g flab = cond(foreign, "Foreign",
"US") if _n == _N
separate price, by(foreign)
scatter price? yhat? weight, ms(oh th i i) mcolor(blue red)
mlabcolor(blue red blue red) lcolor(blue red blue red) c(. . L L)
mlab(. . flab flab) sort legend(off) ytitle(`: var label price')

See also

SJ-5-4  gr0023  . . . . Stata tip 27: Classifying data points on scatter 
plots
        . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. 
Cox
        Q4/05   SJ 5(4):604--606                                 (no 
commands)
        tips for using separate, gray-scale gradation, and text
        characters as class symbols to classify data points on
        a scatter plot


On Fri, Nov 30, 2012 at 9:38 AM, Allan Reese (Cefas)
<allan.reese@cefas.co.uk> wrote:
> A trick I use is to create a second variable containing the label but
> only at the selected points - usually the maximum.
>
> use auto
> regress price wei i.for#c.wei
> predict yhat
> egen maxpoint=max(yhat), by(for)
> sort for yhat
> g flab="US"
> replace flab="Foreign" if for==1
> replace flab="" if yhat!=maxpoint
> scatter price yhat weight, ms(oh i) c(. L) mlab(. flab)
>
> You can use mlabpos and xscale(range()) to allow for fit, or just use
> the graph editor to tweak position.
>
> Allan
>
> On Nov 29, 2012, at 12:28 PM, Max.Livingston@ny.frb.org wrote:
>>> When creating graphs (using a do-file, not the Graph Editor), is
> there a
>>> way to label the data series in the plot area, so the name of the
> series
>>> would appear near the line that is plotted? Here is an example:
>>>
> http://libertystreeteconomics.typepad.com/.a/6a01348793456c970c017d3dfcd
> f73970c-popup
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/






This e-mail message, including attachments, is for the sole use of the intended recipient(s) and may contain confidential or proprietary information.  If you are not the intended recipient, immediately contact the sender by reply e-mail and destroy all copies of the original message.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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