lionel- / ggstance

Horizontal ggplot2 components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Broken 'geom_barh' or stupid user?

r-cheologist opened this issue · comments

Consider the following:

ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(class)) + ggplot2::geom_bar()

This yields
rplot

However

ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(class)) + ggstance::geom_barh()

produces the (broken!?)
rplot01
Where am I getting this wrong?

You also need to flip your aes specification and pass class as y aesthetic:

ggplot(mpg, aes(y = class)) + geom_barh()

Note there was a bug in the version currently on CRAN due to which the above line wouldn't work :/
With current CRAN ggstance you need to pass counth explictly:

ggplot(mpg, aes(y = class)) + geom_barh(stat = "counth")

This is now fixed on github and should be on CRAN within 2 weeks, hopefully next week.