Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: graph change between times


From   Tim <[email protected]>
To   [email protected]
Subject   st: graph change between times
Date   Wed, 07 Apr 2010 18:37:35 +1000

Hello Statalist

Any advice welcome.

Even if you tell me a single command that can do all that I have tried, I will honour you. And I will not regard my time as wasted as I have learned much about -gr tw-.



I have not used a standard dataset, nor have I provided my own data. My raw data is confidential and I don't know what standard dataset would show my problem. I hope my question is sufficiently articulated below.


What I want

I want to display the current (2007) value and the change from 2001 for various categories.



What I did

After searching within Stata, I started with -tw pcarrow-. But I did not like the arrowheads. I could not see how to use options to change the arrowheads to another marker.

So I turned to an overlay of -tw pcspike- and -tw scatter-.



My result

This is the code I ended with:

tw	(pcspike c2001_ bchar2 c2007_ bchar2 if grp==1, horiz) ///
	(pcspike c2001_ bchar2 c2007_ bchar2 if grp==2, horiz) ///
	(pcspike c2001_ bchar2 c2007_ bchar2 if grp==3, horiz) ///
	(pcspike c2001_ bchar2 c2007_ bchar2 if grp==4, horiz) ///
	(pcspike c2001_ bchar2 c2007_ bchar2 if grp==5, horiz) ///
	(sc bchar2 c2007_ , msize(vsmall) mcolor(black)) ///
	,	legend(order(1 - "CPAP" 2 3 4 5) position(4) ring(0) col(1) ///
			label(1 "Ventilation") ///
			label(2 "All hospitals") ///
			label(3 "Tertiary") ///
			label(4 "CPAP accredited") ///
			label(5 "Other hospitals")) ///
		ylabel(1(1)16 ,valuelabel angle(0) nogrid tlen(0)) ///
		ymtick(0.5(1)15.5,grid) ///
		ytitle("Infant characteristics") ///
		yscale(reverse) ///
		xtitle("Percentage of infants in that group who received CPAP") ///
		note("Point is value in 2007; line extends from 2001 value")

The graph it produces is at http://members.iinet.net.au/~timbp/Graph.gph

bchar2 is the baby characteristic coded numerically, with an adjustment for the group (so that separate group lines do not overwrite each other).


Problem 1 (the big problem, and why I posted)

I am having trouble with the legend positioning.
There is a lot of white space in the lower right of the graph so that seems a good place to put the legend. But Intubation has values above 50, as does gestage24-28. -legend position(3)- obscures a point for gestage24-28 and -legend position(5)- obscures a point for intubation.

I would expect -legend position(4)- to give the perfect compromise.
But I cannot see any difference between -legend position(4)- and -legend position(5)-

QUESTION: I know I can move the legend in the graph editor, but is there any way to get the legend slightly higher than -pos(4)- and -pos(5)- produce in the original -graph- command?

SUBQUESTION 1: Should -pos(4)- and -pos(5)- produce noticeable different graphs? If so, why did they not?


Problem 2 (as I'm posting, I might as well get an answer to this)

Several of the graph categories are subcategories of Gestational Age.
I tried specifying a -custom- option to -ylabel- to change that single label to italic, but the result had that label in italic and no other labels.

QUESTION: Can I programmatically change the appearance of a single label? If so, how?


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index