Here is my code
ggplot(mtcars, aes(mpg, hp)) +
geom_point() + theme_clean()
I want to remove the y-axis black line. This is my desired results
Best,
Here is my code
ggplot(mtcars, aes(mpg, hp)) +
geom_point() + theme_clean()
I want to remove the y-axis black line. This is my desired results
Best,
Try this (using theme_classic
, which is kind of close to your desired result, but has both x and y axis lines present):
ggplot(mtcars, aes(mpg, hp)) +
geom_point() + theme_classic() +
theme(axis.line.y = element_blank(), axis.line.x = element_line())
If you type theme_classic
(no parenthesese), you can see all the theme
elements that are used to create that theme. Note that the classic theme has axis.line
applied, which creates both x and y axis lines. If you try only specifying axix.line.y = element_blank()
, it does not work, since theme_classic()
applies axis.line
back over that command - resulting in both lines again. This is why you have to specify both here.
Use the folowing code
library(ggthemes)
ggplot(mtcars, aes(mpg, hp)) +
geom_point() + theme_hc() +
theme(axis.line.y = element_blank(), axis.line.x = element_line())
If you want to have an answer according to your code then
ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
theme_clean()+
theme(axis.line.y = element_blank(), axis.line.x = element_line(), plot.background=element_blank())