02.07.2013 Views

现代统计图形 - 科学网—博客

现代统计图形 - 科学网—博客

现代统计图形 - 科学网—博客

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

54 第四章 元素<br />

1 > par(mar = c(4, 4, 4, 3))<br />

2 > plot(0:10, type = "n", xlab = "", ylab = "", xlim = c(0,<br />

3 + 12))<br />

4 > grid(col = "gray")<br />

5 > title(main = "Demonstration of text in R Graphics",<br />

6 + xlab = "X-axis title", ylab = "Y-axis title")<br />

7 > mtext("Here is \"side = 4\"", side = 4, line = 1)<br />

8 > x = c(6, 4, 6, 8)<br />

9 > y = c(8, 5, 2, 5)<br />

10 > s = c(0, 90, 180, 270)<br />

11 > for (i in 1:4) text(x[i], y[i], sprintf("srt = %d",<br />

12 + s[i]), srt = s[i])<br />

13 > segments(c(6, 0, 6, 12), c(10, 5, 0, 5), c(0, 6,<br />

14 + 12, 6), c(5, 0, 5, 10), lty = c(2, 1, 1, 2))<br />

15 > legend(-0.2, 9.8, c("Upper", "Lower"), lty = 2:1,<br />

16 + cex = 0.8, bty = "n")<br />

Y-axis title<br />

0 2 4 6 8 10<br />

Demonstration of text in R Graphics<br />

Upper<br />

Lower<br />

srt = 90<br />

srt = 0<br />

srt = 180<br />

0 2 4 6 8 10 12<br />

X-axis title<br />

srt = 270<br />

图 4.8: 添加标题、任意文本和周边文本的一个演示<br />

Here is "side = 4"

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!