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]

Re: st: Changing titles of graphs in a loop without doing all the graphs again


From   Benjamin Villena Roldan <[email protected]>
To   [email protected]
Subject   Re: st: Changing titles of graphs in a loop without doing all the graphs again
Date   Sun, 16 Mar 2014 15:45:48 -0300 (ART)

Dear all,

Since I got no replies to my question, I keep researching on my own how to solve my problem. And I figured out. I basically copy the.grec code in my do file following an idea in an old Statalist post
I am sharing this solution in case someone else finds a similar problem at some point. 
I think it is a pity grec codes are seemingly not documented by Stata

Here is my code. I hope it helps

local YS aprobns wordns pcomns 
local YSN APROB WORD PCOM
local T S
local u a
local n : word count `YS'
local newyaxis "Avg Marg Response (SD)"

foreach lab in cage momedu {
	local grlist
	if "`lab'"=="cage" local newxaxis "Age Child"
	if "`lab'"=="momedu" local newxaxis "Years Mom Education"
. 	forv j = 1/`n' {
		local y : word `j' of `YS'
		local yn : word `j' of `YSN'
		graph use d`y'dL5`y'_`lab'_`T'`u'
		local newtitle "`yn'(t-5) => `yn'(t)"
		
		*Idea comes from a post in Statalist 
		*http://www.stata.com/statalist/archive/2008-07/msg00932.html
		gr_edit .xaxis1.title.text = {}
		gr_edit .xaxis1.title.text.Arrpush `newxaxis'
		
		gr_edit .yaxis1.title.text = {}
		gr_edit .yaxis1.title.text.Arrpush `newyaxis'
		
		gr_edit .title.text = {}
		gr_edit .title.text.Arrpush `newtitle'
		
		graph rename d`y'dL5`y'_`lab'_`T'`u' Nd`y'dL5`y'_`lab'_`T'`u'
		graph save Nd`y'dL5`y'_`lab'_`T'`u', replace
		local grlist `grlist' Nd`y'dL5`y'_`lab'_`T'`u'
	}	
	
	graph combine `grlist', `options' name(SP`lab', replace) ycom xcom rows(1) cols(3)	
}

graph combine SPcage SPmomedu , `options' name(SP_cage_momedu_`T'`u', replace) rows(2) cols(1)
graph save SP_cage_momedu_`T'`u', replace
graph export SP_cage_momedu_`T'`u'.eps, replace


----- Original Message -----
From: "Benjamin Villena Roldan" <[email protected]>
To: [email protected]
Sent: Saturday, March 15, 2014 6:49:16 PM
Subject: st: Changing titles of graphs in a loop without doing all the graphs again



Dear statalist

I have various dozens of graphs I computed using margins from a complicated model. 
My problem is I need to change their titles now.
Since it took several days to compute all of them, I am wondering if there is a way I could edit just the titles of these graphs without running the whole thing again. Of course, the cumbersome way to do it is just using the graph editor, but it will be too time-consuming. 

I hope you can help me

Best

B.
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index