Statalist


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

st: re: the future of statistical computing


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: the future of statistical computing
Date   Mon, 26 Jan 2009 09:24:25 -0500

<>
Timothy wrote

----------------
x <- 0:10
y <- c(1,1,1,1.5, 2,3,4,4,4.5,5,98)
y2 <- c(0,0,0.5,1.5,2,1.5,2,4,8,9,9)
plot(x,y,type="b",ylim=c(0,10), xlab="This is the number of days \n since a particular day")
lines(x,y2,type="b",col="red")
legend(0,10,legend=c("Line 1","Line 2 is really long. So I'd like", "to split it into two lines"),col=c("black","red","white"),lwd=1)
-----------------

I can run that with no problem in R. I do wonder, though, what it means to have a vertical line segment for series y beyond the last graphed point. I think it might be more sensible to graph only those values which you want to see:

-----------------
clear
mata: mata clear
mata
st_matrix("y",(1,1,1,1.5, 2,3,4,4,4.5,5,98)')
st_matrix("y2",(0,0,0.5,1.5,2,1.5,2,4,8,9,9)')
end
set obs 11
g x = _n - 1 in 1/10
svmat y
svmat y2
twoway conn y1 y21 x if !mi(x), xti("This is the number of days" "since a particular day") /// lcolor(black red) msymb(Oh Oh) leg(ring(0) pos(10) col(1) lab(1 "Line 1") /// lab(2 "Line 2 is really long." "So I'd like to split it into two lines"))
----------------

As you can see it is no problem to split either axis labels or legend keys into multiple lines. That is, I believe, a recent enhancement to - graph-. It doesn't look much more complicated to produce the Stata graph than the R graph.

Kit

Kit Baum, Boston College Economics and DIW Berlin
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index