Things to note:

  1. It doesn’t seem to matter what you use for x in the aes statement , x=color, x=factor(1) both work
  2. In aes(x=colour, fill=I(colour)) if you use fill=I(colour) i.e. use the literal colour values to colour the bar chart, then no legend is produced by ggplot2. If you need a legend, then use fill=colour in the AES to force a legend and add scale_fill_manual() to make a legend with the colours you want (see blog post on how to make literal colour pie charts with a legend). Not sure if this is a bug in ggplot2 or if there is an option to force a legend when using literal colour values.
  3. In p= p + geom_bar(stat="count") you need stat="count if you want ggplot to count the number of occurrences (in this case AFAICT all colours only appear once for most instagram vancouver vancouver 2016 photos for any particular hour!), i.e. your data is un-summarized. If your data is summarized then you can use stat="identity"

And here’s what the bar chart looks like: 1st3-ig-van-01january-2016-barchart

The Code

First the code,first3-ig-van-01january2016-barchart.R

data3 = read.csv(file="01january2016-1st3datapoints.csv", 
p = ggplot(data=data3, aes(x=colour, fill=I(colour)))
p= p + geom_bar(stat="count")

p, width = 26.666666667, 
height = 26.666666667, dpi = 72, limitsize = FALSE)

The Data

Then the data, 01january2016-1st3datapoints.csv:


Leave a comment on github