Here I have theme_light() but in the plot I still have the x/y axis & legend grid. I want to remove those and only have my light background plot 'pic'. When I use theme_void -> it removes the legend but then the background is void. Any idea how to solve this so I only have a white background and my plot?
pic <- ggplot(data = art_dat, mapping = aes(x = x, y = y, group = path_id,
color = step_id)
)
geom_path(
size = .9,
alpha = 1000, #transparency of the lines
show.legend = FALSE
)
coord_equal()
theme_light()
scale_color_scico(palette = "berlin")
CodePudding user response:
EDIT: Updated as you have posted an image. You do not have a legend, so you do not need to remove it. You want to remove the axis lines, ticks, text, title and maybe(?) the panel grid lines:
pic <- ggplot(data = art_dat, mapping = aes(x = x, y = y, group = path_id,
color = step_id)
)
geom_path(
size = .9,
alpha = 1000, #transparency of the lines
show.legend = FALSE
)
coord_equal()
theme_light()
scale_color_scico(palette = "berlin")
theme(
axis.line = element_blank(),
axis.text = element_blank(),
axis.ticks = element_blank(),
axis.title = element_blank(),
panel.grid.major = element_blank(), # optional - remove gridlines
panel.grid.minor = element_blank() # optional - remove gridlines
)
CodePudding user response:
If you add some adjustments to theme void, you can get rid of the legend. In addition, you can make the legend white with the plot.background argument. In the example below I made it red to show that there are no margins left and such. There is a row of white pixels, but I don't know what to do against that.
library(ggplot2)
p <- ggplot(mpg, aes(displ, hwy, colour = cyl))
geom_point()
p theme_void()
theme(
legend.position = "none",
plot.background = element_rect(fill = "red", colour = NA)
)

Created on 2022-01-18 by the reprex package (v2.0.1)

