I have a bar-chart that looks like this:
ggplot(mtcars, aes(x = cyl, y = hp)) +
geom_bar(stat = "identity", width = 1)
I want to tweak the geom_bar
parameters so that the bars are shifted to the right (not centred)...
Try this:
ggplot(mtcars, aes(x = cyl, y = hp)) +
geom_bar(stat = "identity", width = 1, position = position_nudge(x = 0.5))
How I figured this out: Went to ?geom_bar
and saw that there was a postion argument and a link to ?position_dodge
. Look at the examples there and made modifications to your code. Seems to be a satisfactory solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With