Hello,

I am trying to create a series of boxplots with the following data, three
columns, "Day" (1 or 2), "Site" (1-4), and "VO2" (some values missing for
some Sites or Days)

> CorbulaMR3
   Day Site       VO2
1    1    1  88.92223
2    1    1  86.17873
3    1    1  61.08950
4    1    1 190.47922
5    1    1  98.65930
6    1    1 121.03549
7    1    1  67.88404
8    1    1 126.29497
9    1    1 109.47173
10   1    1 113.81467
11   2    1  78.09781
12   2    1  43.97586
13   2    1  63.17635
14   2    1  20.20365
15   2    1  95.25985
16   2    1  47.32347
17   2    1  30.43341
18   2    1  44.19395
19   2    1        NA
20   2    1        NA
21   1    2  33.80003
22   1    2  26.00926
23   1    2  39.80552
24   1    2  36.59985
25   1    2  48.67881
26   1    2  36.94679
27   1    2  33.72825
28   1    2  36.44749
29   1    2  14.97611
30   1    2  26.97976
31   2    2  31.36923
32   2    2  36.02215
33   2    2  40.00660
34   2    2  36.73098
35   2    2  30.90854
36   2    2  48.77643
37   2    2  24.68537
38   2    2        NA
39   2    2        NA
40   2    2        NA
41   1    3  48.09866
42   1    3  23.80070
43   1    3  36.72271
44   1    3  32.32115
45   1    3  29.50701
46   1    3  50.68163
47   1    3  30.04234
48   1    3  30.90461
49   1    3  45.39888
50   1    3  32.61571
51   2    3  20.69708
52   2    3  21.17658
53   2    3  32.44907
54   2    3  34.04048
55   2    3  45.97381
56   2    3  40.34278
57   2    3  21.67128
58   2    3  22.45179
59   2    3        NA
60   2    3        NA
61   1    4  39.35840
62   1    4  29.32294
63   1    4  49.28409
64   1    4  50.75344
65   1    4  43.53663
66   1    4  33.76173
67   1    4  36.40901
68   1    4  36.16992
69   1    4  49.99144
70   1    4        NA
71   2    4  28.64131
72   2    4  22.69317
73   2    4  42.31203
74   2    4  31.17968
75   2    4  59.36813
76   2    4  44.53866
77   2    4  45.96834
78   2    4  33.16604
79   2    4  35.57714
80   2    4  35.46922

I have the following code which works well except that in the legend the
fill colour for Day 1 and Day 2 is left blank. Instead the little boxes next
to the labels (Day 1, Day 2) are both unfilled (white). The boxplots are
filled properly, but without the fill colour in the legend its difficult
decipher the plot

p=ggplot(CorbulaMR3,aes(factor(Site),VO2))
p+geom_boxplot(aes(fill=factor(Day)))+scale_fill_manual('Day', breaks =
c('Day 1', 'Day 2'),
+     values = c('grey','black'),
+     labels = c('Day 1', 'Day 2'))+xlab('Sampling Site')+ylab('Metabolic
Rate')+opts(title="Sampling")

I've played around and if I don't use the scale_fill_manual() and instead
simply plot using

p+geom_boxplot(aes(fill=factor(Day)))

the legend boxes are filled, but obviously plot/legend is not labeled in the
manner I would like and I don't much care for the default colours.

Any thoughts on why when I use the scale_fill_manual() the fill colours are
not shown in the legend? I'm pretty sure its something simple.

I'm working on a Mac with R 2.12.0

Thank you,

Nate

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to