Skip to content

Instantly share code, notes, and snippets.

@yoavram
Created May 19, 2013 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoavram/5606906 to your computer and use it in GitHub Desktop.
Save yoavram/5606906 to your computer and use it in GitHub Desktop.
How to change where the horizontal axis crosses the vertical axis in geom_bar? The result of http://stackoverflow.com/questions/16537401/how-to-change-where-the-horizontal-axis-crosses-the-vertical-axis-in-geom-bar
library(ggplot2)
data <- c(0.3,0.4,0.5,0.6,0.7,0.8)
qplot(x=1:6, y=data - 0.5, geom="bar", stat="identity") +
scale_y_continuous(breaks=c(-0.5,-0.25,0,0.25,0.5), limits=c(-0.5,0.5), labels=c(0,0.25,0.5,0.75,1.0)) +
labs(y="",x="")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment