[R] graph displays

Sarah Goslee sarah.goslee at gmail.com
Mon Jun 25 19:42:57 CEST 2012


There's no way we can tell you the "best way" to display your
information, because we don't know anything about it. The best display
method has a lot to do with what the data are, and what you're trying
to illustrate. That said, here are two possibilities, one using the
bar graph you requested, and both using only base graphics.

# PLEASE use dput() to provide your data, rather than pasting it in
testdata <- structure(list(Source = c("A", "B", "C"), X1000s = c(47L, 37L,
17L), X600s = c(63L, 64L, 62L), X500s = c(75L, 45L, 25L), X250s = c(116L,
11L, 66L), X100s = c(125L, 25L, 12L), X50s = c(129L, 19L, 29L
), X10s = c(131L, 61L, 91L), X5s = c(131L, 131L, 171L), X3s = c(131L,
186L, 186L), X1s = c(131L, 186L, 186L)), .Names = c("Source",
"X1000s", "X600s", "X500s", "X250s", "X100s", "X50s", "X10s",
"X5s", "X3s", "X1s"), class = "data.frame", row.names = c("1",
"2", "3"))

barplot(as.matrix(testdata[,-1]), beside=TRUE, col=1:3)
legend("topleft", LETTERS[1:3], col=1:3, pch=15)

plot(1:10, testdata[1, -1], type="b", ylim=c(0, 200), xaxt="n", col=1)
axis(1, 1:10, colnames(testdata)[-1])
lines(1:10, testdata[2, -1], type="b", col=2)
lines(1:10, testdata[3, -1], type="b", col=3)
legend("topleft", LETTERS[1:3], col=1:3, pch=15)

Sarah

On Mon, Jun 25, 2012 at 12:24 PM, MSousa <ricardosousa2000 at clix.pt> wrote:
>
> Good Afternoon, I'm trying to create a graph that displays the best way the
> following information.
>
>     For instance organized by bar graph, A, B, C
>
>
>
> Source X1000s X600s X500s X250s X100s X50s X10s X5s X3s X1s
> 1      A     47    63    75   116   125  129  131 131 131 131
> 2      B     37    64    45    11    25   19   61 131 186 186
> 3      C     17    62    25    66    12   29   91 171 186 186
>
> thanks
>
>

-- 
Sarah Goslee
http://www.functionaldiversity.org



More information about the R-help mailing list