Reduction of elements in vector graphics by removing/merging invisible objects

Dear team,
I love that it is possible to create vector graphics with ggplot2.
But plotting scatter plots or other plots with many elements will lead to files with MANY objects, which I would love to avoid.
I could export them into png, but would lose the vectors or I could merge points using e.g. geom_hex.
But I would love to include only visible points into the final vector graphics and remove all hidden elements. Is there a way to do this?

Thank you very much!
Best
Felix

minimal example:


plot_data <- data.frame(x = runif(100000),
						y = runif(100000))

p <- plot_data %>% 
    ggplot2::ggplot(aes(x = x,
                       y = y,
                      fill = y)) +
    ggplot2::geom_point(shape = 21,
               color = "black",
               stroke = 0.2)
	
ggplot2::ggsave(file="test.svg", plot=p, width=10, height=8)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.