I'm trying to create a histogram without a frame (top and right lines), but with x and y axes shown in R
using ggplot
.
I am using the solution to this question: remove grid, background color and top and right borders from ggplot2
Specifically:
library(ggplot2)
ggplot(faithful, aes(x=eruptions)) +
geom_histogram(binwidth=0.2,colour="black",fill="white")+
theme_bw()+theme(aspect.ratio=0.618)+
theme(plot.background = element_blank(),
panel.grid.major = element_blank(),
panel.border = element_blank())+
theme(axis.line.y = element_line(color = 'black'))
The last line, however, does not seem to have a visible effect.
To reiterate, I would like: y-axis shown, ticks on the x-axis, and preferably the origin of axes at (0,0).
As @user20650 kindly suggested in the comments, theme_classic()
is a simple option to do what I was trying to achieve. Additionally, to move the x-axis just below the bars, scale_y_continuous(expand=c(0,0))
can be used.
Thank you!