将绘图另存为 SVG,删除填充符号上的笔划
Save plot as SVG removing stroke on filled symbols
我一直在 ggplot2 中使用填充符号,导出到 png 时从未遇到过任何问题。但是,当我导出为 svg 时,对于某些形状(三角形和菱形),符号的一侧没有描边。
这最初是在我绘制一些地图时发生的,所以我试图用简单的示例图来复制这个问题——它仍然在发生。我无法理解是什么导致符号的一侧像这样消失。这是我在导出为 svg 时没有指定的东西吗?或者某处有错误?任何帮助将不胜感激。
举个例子:
以及创建此图像的代码:
library(tidyverse)
plot =
data_frame(x = 1:5, y = 1:5, group = c("tri", "sq", "tri", "sq", "dia")) %>%
ggplot(aes(x,y, shape = group)) +
geom_point(fill = "red", colour = "black", size = 4) +
scale_shape_manual(values = c(23,22,24)) +
theme_bw()
plot %>% ggsave("test.svg", ., height = 10, width = 10, units = "cm")
注意:我曾尝试使用 svglite()
直接导出 - 同样的事情发生了。
这似乎是 svglite
中的错误:
Missing edges in svg file for some point characters when background color is set
首次报道于 ggplot2
github:
我一直在 ggplot2 中使用填充符号,导出到 png 时从未遇到过任何问题。但是,当我导出为 svg 时,对于某些形状(三角形和菱形),符号的一侧没有描边。
这最初是在我绘制一些地图时发生的,所以我试图用简单的示例图来复制这个问题——它仍然在发生。我无法理解是什么导致符号的一侧像这样消失。这是我在导出为 svg 时没有指定的东西吗?或者某处有错误?任何帮助将不胜感激。
举个例子:
以及创建此图像的代码:
library(tidyverse)
plot =
data_frame(x = 1:5, y = 1:5, group = c("tri", "sq", "tri", "sq", "dia")) %>%
ggplot(aes(x,y, shape = group)) +
geom_point(fill = "red", colour = "black", size = 4) +
scale_shape_manual(values = c(23,22,24)) +
theme_bw()
plot %>% ggsave("test.svg", ., height = 10, width = 10, units = "cm")
注意:我曾尝试使用 svglite()
直接导出 - 同样的事情发生了。
这似乎是 svglite
中的错误:
Missing edges in svg file for some point characters when background color is set
首次报道于 ggplot2
github: