[R] Having trouble controlling plot() output (e.g., color)

David Wolfskill
Fri, 03 Feb 2012 22:28:35 -0000

I expect that there's something glaringly obvious that I'm overlooking,
as I'm justr getting back involved in using R after a several-month
hiatus (from R).  So I welcome clues.

When I invoke plot(), merely specifying a data.frame with 2 columns,
specify the plot type ("type") of "p" ("points"),
and that I want the
point to be green ('col = "green"'), sometimes I get the
expected
result; other times I get horizontal black lines instead -- and he
behavior appears to be consistent for a given data.frame, but I don't
seem to be able to predict (for a new data.frame) which behavior I'll
get ... and I'm beginning to wonder about what's left of my sanity. :-}

> R.Version()
$platform
[1] "i386-portbld-freebsd8.2"

$arch
[1] "i386"

$os
[1] "freebsd8.2"

$system
[1] "i386, freebsd8.2"

$status
[1] ""

$major
[1] "2"

$minor
[1] "14.1"

$year
[1] "2011"

$month
[1] "12"

$day
[1] "22"

$`svn rev`
[1] "57956"

$language
[1] "R"

$version.string
[1] "R version 2.14.1 (2011-12-22)"

> dump("foo", file = "")
foo <-
structure(list(X1.5 = 1:5, X6.10 = 6:10), .Names = c("X1.5",
"X6.10"), row.names = c(NA, -5L), class =
"data.frame")
> dump("bs_mean", file = "")
bs_mean <-
structure(list(month = structure(1:13, .Label = c("2011_01",
"2011_02", "2011_03", "2011_04",
"2011_05", "2011_06", "2011_07",
"2011_08", "2011_09", "2011_10",
"2011_11", "2011_12", "2012_01"
), class = "factor"), `bs$log_t` = c(1.2026062533015,
1.27747221429551,
1.30908704746547, 1.35386015390552, 1.36891795176966, 1.50313159806506,
1.41951401509, 1.25753555559904, 1.21365151487245, 1.33079015825995,
1.50334927085608, 1.39072924382553, 1.44966367892355)), .Names =
c("month",
"bs$log_t"), row.names = c(NA, -13L), class =
"data.frame")
> attributes(foo)
$names
[1] "X1.5"  "X6.10"

$row.names
[1] 1 2 3 4 5

$class
[1] "data.frame"

> attributes(bs_mean)
$names
[1] "month"    "bs$log_t"

$row.names
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13

$class
[1] "data.frame"

> plot( bs_mean, type = "p", col = "green" )
> plot( foo, type = "p", col = "green" )


The first plot() invocation -- the one that has the data I actually
care about, of course -- displays a set of 13 horizontal bars, each
of which appears to be black.  [I actually *like* the horizontal
bars; I'd like to be able to control the color, though.]

The second invocation draws a set of 5 green "points" (as I would
expect).

How may I plot "bs_mean" in a non-black color?

Thanks.

Peace,
david
--
David H. Wolfskill				david at catwhisker.org
Depriving a girl or boy of an opportunity for education is evil.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL:
<https://stat.ethz.ch/pipermail/r-help/attachments/20120203/6fbf571a/attachment.bin>