With the following code I can remove top and right borders along with other things. I wonder how to remove the right border of the ggplot2
graph only.
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
p + theme_classic()
With the following code I can remove top and right borders along with other things. I wonder how to remove the right border of the ggplot2
graph only.
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
p + theme_classic()
the theme system gets in the way, but with a little twist you can hack the theme elements,
You can just remove both borders (as it's in the first place with
theme_classic()
), and then add one withannotate()
:(The idea is from: How to add line at top panel border of ggplot2)
By the way, you of course don't need to use
theme_classic()
. If you use a theme that has different default borders, you can switch them on/off with thetheme()
function's parameterspanel.border
(sets all borders) andaxis.line
(sets separate axis "borders").For example (for default theme):