Reputation: 2493
I would like to visualize publication dates by academic discipline in a ggplot2 qplot.
data$DISCIPLINE
is my factor containing 10 levels.
This is how my data looks like:
> head(cbind(data$DATE,data$DISCIPLINE))
[,1] [,2]
[1,] "2001" "Politikwissenschaften"
[2,] "2006" "Geographie"
[3,] "1999" "Soziologie"
[4,] "2013" "Architektur"
[5,] "2007" "Soziologie"
[6,] "2004" "Soziologie"
I produced the qplot as follows:
require(ggplot2)
MYPLOT <- qplot(data$DATE, data$DISCIPLINE)
MYPLOT + geom_point(aes(size=..count..), stat="bin") + scale_size(range=c(0, 15))
Of course I want bins with 0 observations not to be plotted - this is why I set the range minimum to 0. At least, that worked.
However strangely, single observations received two points in the plot. See for example for the level "Soziologie", there are 2 points in the plot in the early 80s, despite there only being a single observations in my dataset.
Is this an error in ggplot2? How can I correct it?
Upvotes: 1
Views: 202
Reputation: 4459
Does this do what you want?
MYPLOT <- qplot(data$DATE, data$DISCIPLINE)
MYPLOT + geom_point() + stat_sum(aes(size = ..n..))
Upvotes: 2