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

Re: st: twoway rspike - with marker labels placed in the center of the spike


From   Nick Winter <[email protected]>
To   [email protected]
Subject   Re: st: twoway rspike - with marker labels placed in the center of the spike
Date   Wed, 27 Jul 2005 14:18:16 -0400

Assuming you've got data


lo hi state fips
1. 5 10 1 CA
2. 3 9 2 VA
3. 7 15 3 AK


Then this is a start:

. gen mid = (lo+hi)/2
. graph twoway rspike lo hi fips || scatter mid state ,
msym(none) mlab(fips) mlabangle(vertical)
mlabpos(0) xsca(ra(0 4)) legend(off)

The only problem is that the bars run over the labels. You could put the labels next to the spikes by omitting the mlabpos() option. Or you could get fancier and create two bars, one above and one below the label. Something like:


. gen midlo = mid - 0.5

. gen midhi = mid + 0.5

. graph twoway rspike lo midlo state || rspike midhi hi state || scatter mid state ,
msym(none) mlab(fips) mlabangle (vertical) mlabpos(0) xsca(ra(0 4)) legend(off)

Here you would have to experiment with the size of the gap in the generate statements; the necessary gap would depend on the y axis range and size of the labels.

--Nick Winter



At 02:03 PM 7/27/2005, you wrote:

Does anyone know how to create spike plots with a marker label centered
on the midpoint of the spikes, using for example fips codes

Something like

|                                  |
|                         |        |
|               |         VA      AK
|               CA        |        |
|               |                  |
|____________________________________

Only with the fips codes rotated 90 degrees
Regards,
John

*
*   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