I have a data frame with cols "x", "y" and ordinary rows ("x" and "y" can be treated as collections of numbers) . All I want is to plot a bar-chart with x tied to "x" and y tied to "y". Tried to use
geom_bar(data = xs, aes(x, y), stat = "identity", alpha = 0.5)
stat_identity(data = xs, aes(x, y), geom = "bar", alpha = 0.5)
The problem is that you want to do a
bar_plot for data that contains multiple observations in
y for a single
geom_bar it is simply summing (binning) the values.
When you use
stat_identityit doesn't sum but it keeps the information of the number of occurrences for each values. Hence the alpha set to a much lower values for the extreme values (0 and 10 only have a single observation each).
So if you want to have a graph like the one you obtained with
stat_idendity, you need to drop the information regarding the number of occurences. It's very easy since you only have repetition of a single value.
ggplot(data = xs[!duplicated(xs),], aes(x=x, y=y)) + geom_bar(stat = "identity")