Hi everybody,
I wrote a short program for a Stata programming class that I teach that pulled together many aspects of Stata for my students. But, the program had an interesting issue. When I run the program code below it does what it is supposed to do. It creates three individual graphs, a graph used as a title, and combines them into one graph. Each of the three graphs shows a title based on the variable label.
Here is the problem. If I run the program a second time, the titles disappear or are not shown. In fact, I lose the ability to display titles on any graphs created later by any method. I also cannot add titles using the graph editor.
I have tried this on two computers with the same results and I have tried changing different parts of the program to try to isolate where the problem appears, but I am not seeing the cause of this issue.
I would appreciate any ideas that you have about how my program may have caused this behavior.
Here is the program code with data:
Best,
Alan
I wrote a short program for a Stata programming class that I teach that pulled together many aspects of Stata for my students. But, the program had an interesting issue. When I run the program code below it does what it is supposed to do. It creates three individual graphs, a graph used as a title, and combines them into one graph. Each of the three graphs shows a title based on the variable label.
Here is the problem. If I run the program a second time, the titles disappear or are not shown. In fact, I lose the ability to display titles on any graphs created later by any method. I also cannot add titles using the graph editor.
I have tried this on two computers with the same results and I have tried changing different parts of the program to try to isolate where the problem appears, but I am not seeing the cause of this issue.
I would appreciate any ideas that you have about how my program may have caused this behavior.
Here is the program code with data:
Code:
sysuse auto, clear **# Graphing Program capture program drop graphit program graphit local ttl : variable label `0' quietly summarize `0', meanonly local mean = strofreal(r(mean),"%4.1f") #d ; kdensity `0', normal normopts(lpattern(longdash)) lwidth(vthick) lcolor(maroon) title(`ttl', position(11)) xtitle("") note("mean=`mean'") yscale(off) xlabel(, noticks) graphregion(color(white)) legend(off) xline(`r(mean)', lwidth(medthick) lpattern(dash)) scheme(s2color) nodraw name(`0', replace); #d cr end graphit mpg graphit price graphit displacement #d ; graph twoway scatteri 0 0 100 100, m(i) xscale(off) yscale(off) ylabel(, nogrid) text(50 50 "Kernal Density" "Plots", size(*3)) graphregion(color(white)) nodraw name(title, replace); #d cr graph combine mpg price displacement title, nocopies graphregion(color(white)) name(cmbplot, replace)
Alan
Comment