0

I wanted to start by saying that I've perused the other questions here including the one at this link. I tried pretty much copy/pasting the examples there but I'm still having the issue. I am also pretty new to R in general

FWIW I'm using R studio on ubuntu 13.10 to do this. I have a vector of values 1:8773 or so of square footages of buildings. When I try

qplot(sqFootage, geom = "histogram", colour = "red")

I get this picture :.

enter image description here

Clearly that's not red; it does the same thing for other colors (green, dark green, dodgerblue, firebrickred4) and I'm not sure why.

I've imported the ggplot2 library (or else it wouldn't even show up I guess). Any advice?

Community
  • 1
  • 1
user3246152
  • 111
  • 6

1 Answers1

5

Replace colour with fill:

qplot(sqFootage, geom = "histogram", fill = I("red"))

The parameter colour is used to define the colours of the borders of the rectangles.

Furthermore, you have to use the I function. Otherwise, "red" is interpreted as a factor (as Ben Bolker points out).

Sven Hohenstein
  • 80,497
  • 17
  • 145
  • 168
  • 2
    I think this isn't quite right. In `qplot` (*not* in `ggplot()`), `fill="red"` creates a one-element factor with level `"red"`; it's a coincidence that ggplot's default colour for a single-level factor is reddish. if you actually want the colour, or fill, to be red, you **must** use `I("red")`. (For an illustration, try `fill="blue"` and see what happens ...) – Ben Bolker Feb 02 '14 at 16:04
  • @BenBolker I modified the answer accordingly. Thanks for pointing this out! – Sven Hohenstein Feb 02 '14 at 17:53