r - geom_bar tied exactly to x and y axis (without aggregating) -


i have data frame cols "x", "y" , ordinary rows ("x" , "y" can treated collections of numbers) . want plot bar-chart x tied "x" , y tied "y". tried use geom_bar(stat='identity') produce unexpected me result - figured out sums y-values of corresponding bar x-value. when tried stat_identity(geom='bar') result nice, 1 problem occured: can't figure out how set fixed alpha stat_identity (seems automatically binds number of samples corresponding bar x-value). here examples:

ggplot() +     geom_bar(data = xs, aes(x, y), stat = "identity", alpha = 0.5) 

enter image description here

ggplot() +     stat_identity(data = xs, aes(x, y), geom = "bar", alpha = 0.5) 

enter image description here

so, once again, goal: to plot bar-chart x tied "x" , y tied "y". hence second example solves it, there issue alpha parameter.

update: file test data can found here. or github gist there.

the problem want bar_plot data contains multiple observations in y single x.
when using geom_bar summing (binning) values.
when use stat_identityit doesn't sum keeps information of number of occurrences each values. hence alpha set lower values extreme values (0 , 10 have single observation each).

so if want have graph 1 obtained stat_idendity, need drop information regarding number of occurences. it's easy since have repetition of single value.

ggplot(data = xs[!duplicated(xs),], aes(x=x, y=y)) +   geom_bar(stat = "identity") 

enter image description here


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -