[R] polygon graph

Jose Narillos de Santos narillosdesantos at gmail.com
Wed Dec 2 13:49:52 CET 2009


Hi all,

I have a matrix dd with dates and data. i WANT to create a grpah with shade
between the line and the zero axis. I´m trying to use polygon but something
doesn´ t work

Imagine.

I want to plot

g<-read.table("dd.txt", col.names=c("fecha","DP"))

g$fecha <- as.Date(g$fecha, format="%d/%m/%Y")

t<-g$fecha
st<-length(g$DP)

ft<-plot(t,g$DP,type="l",ylab="DP")

polygon(c(1, 1:st, st), c(0, g$USGDP, 0), col = "blue")

abline(h = 0, lwd = 1, col = "black")

If I ommit ploygon line the doc works properly (it plots a graph line).

But I want to colur the area below or over the line and the zero axis.

Can you guide or indicate because in this case polygon doesn´t work.

I attach the two files.



Thanks in advance for all.
-------------- next part --------------
31/03/1948	12.9
30/06/1948	24.9
30/09/1948	45.6
31/12/1948	24.2
31/03/1949	21.1
30/06/1949	-21.1
30/09/1949	-20.5
31/12/1949	-21.6
31/03/1950	23.8
30/06/1950	27.4
30/09/1950	10.4
31/12/1950	13.4
31/03/1951	10.3
30/06/1951	28.9
30/09/1951	26.8
31/12/1951	25.2
31/03/1952	24.9
30/06/1952	23.3
30/09/1952	22
31/12/1952	25.2
31/03/1953	26.1
30/06/1953	26.7
30/09/1953	25.4
31/12/1953	0.4
31/03/1954	-21.9
30/06/1954	-22.5
30/09/1954	-02.8
31/12/1954	22.8
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pruplot.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091202/602be54e/attachment-0002.txt>


More information about the R-help mailing list