Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: String variable as text labels below x-axis


From   Nick Winter <[email protected]>
To   [email protected]
Subject   Re: st: String variable as text labels below x-axis
Date   Thu, 08 Jul 2004 10:06:47 -0400

I don't fully understand your data structure and/or the graph you are plotting...if you are doing more than one course per plot, then things would get very messy.

But, to get the name(s) listed at a constant height across the graph, something like this might help. I'm assuming that your name variable has the multiple names, separated by commas, so your data look something like this:

name a b c Y
1. Nick Winter, Nick Cox, Bill Gould 1 1.2 1.2 98-99
2. Nick Winter 1.1 1.6 .7 99-00
3. Nick Cox 1.2 1 1.4 00-01
4. Vince Wiggins, Bill Gould 1 .6 .6 01-02

If it is something else, you will need to modify accordingly.

. split name , gen(name_1) parse(", ")

This creates variables name_1 through name_5, each containing one (or no) instructor name.

. gen height1 = -0.1
. gen height2 = -0.2
. gen height3 = -0.3
. gen height4 = -0.4
. gen height5 = -0.5

This creates the variables to indicate the vertical placement of each name; this may take some manual tweeking to get exactly right.

. twoway sc a b c Y, c(l l l) || ///
sc height1 Y , mlab(name_1) mlabpos(0) mlabstyle(p1) mstyle(none) || ///
sc height2 Y , mlab(name_2) mlabpos(0) mlabstyle(p1) mstyle(none) || ///
sc height3 Y , mlab(name_3) mlabpos(0) mlabstyle(p1) mstyle(none) || ///
sc height4 Y , mlab(name_4) mlabpos(0) mlabstyle(p1) mstyle(none) || ///
sc height5 Y , mlab(name_5) mlabpos(0) mlabstyle(p1) mstyle(none) ///
xlabel( ,val) xscale( range(0.7,4.3) ) legend(off) ylab(0[.5]2)

You may need to fiddle with the xscale(range) to get the xscale wide enough, and you may need to fiddle with the ylab() option to get the labelling where you want it.

--Nick Winter


At 06:35 AM 7/8/2004 -0700, you wrote:

Hi Statalisters,

I have a dataset including three numeric indices (say
a, b, c) for the quality of a course, the number of
the students of the course (N), the year (Y) of the
course as a labeled numeric variable (1->"98-99",
2->"99-00" etc.) and a string variable (name)
containing the name(s) of the instructor(s). The
number of instructors varies across years from 1 to 5
thus my string variable is quite long in some cases. I
want to produce a graph showing the evolution of these
three indices through time. I have used something
like:

. sc a b c  Y,xlabel( ,val  ) c(l l l ) mlabel(name)

but I am looking for a more elegant graph. More
specifically I would like to see the name or names of
the instructors plotted (stacked beneath each other if
more than one) below the ylabels (98-99, 99-00 ...) or
in a similar way within the graph in a constant
height.

I am asking this because although it's possible to
achieve such a graph using the added_text_options I
suppose or by editing the graph outside Stata, I have
lots of such datasets to plot.

Thanks for any ideas

Nikos Pantazis

Biostatistician





__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
--------------------------------------------------------
Nicholas Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government [email protected] e
308 White Hall falcon.arts.cornell.edu/nw53 w
Cornell University
Ithaca, NY 14853-4601

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index