2
我使用ggplot2::ggsave()
创建了一个svg。我将svg嵌入到html文件中。但是,我发现svg周围有一个边框。我如何删除此边框?将ggsave svg嵌入到html文件中时删除边框
tl; dr版本:download this html,我如何去除内联svg的边界?
这里是我用来创建SVG代码:
的statistics_data
dput
:
statistics_data <-
structure(list(Category = structure(c(5L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 5L, 5L, 5L, 5L, 2L, 2L, 3L, 3L, 3L, 3L,
4L, 5L, 3L, 5L, 5L, 5L, 1L, 1L, 1L), .Label = c("Online Presence",
"Social Presence", "Web Design", "Web Development", "Website Content"
), class = "factor"), Category_count = c(9L, 14L, 14L, 14L, 14L,
14L, 14L, 14L, 14L, 14L, 14L, 14L, 9L, 9L, 9L, 9L, 2L, 2L, 5L,
5L, 5L, 5L, 1L, 9L, 5L, 9L, 9L, 9L, 14L, 14L, 14L), Category_name = c("Website Content (9)",
"Online Presence (14)", "Online Presence (14)", "Online Presence (14)",
"Online Presence (14)", "Online Presence (14)", "Online Presence (14)",
"Online Presence (14)", "Online Presence (14)", "Online Presence (14)",
"Online Presence (14)", "Online Presence (14)", "Website Content (9)",
"Website Content (9)", "Website Content (9)", "Website Content (9)",
"Social Presence (2)", "Social Presence (2)", "Web Design (5)",
"Web Design (5)", "Web Design (5)", "Web Design (5)", "Web Development (1)",
"Website Content (9)", "Web Design (5)", "Website Content (9)",
"Website Content (9)", "Website Content (9)", "Online Presence (14)",
"Online Presence (14)", "Online Presence (14)")), .Names = c("Category",
"Category_count", "Category_name"), row.names = c(NA, -31L), class = "data.frame")
使用ggplot2
创建一个饼图:
p <- ggplot(data = statistics_data,
aes(x = factor(1), fill = factor(Category))
) +
geom_bar(width = .2, stat = "bin") +
xlab('') +
ylab('') +
theme(axis.ticks = element_blank(),
axis.text.y = element_blank(),
panel.grid.major=element_blank(),
panel.background = element_rect(fill = 'transparent'),
plot.background = element_rect(fill = 'transparent'),
legend.background = element_rect(fill = 'transparent'),
panel.border = element_rect(colour = NA, fill = NA)) +
scale_fill_manual(values = c("Online Presence" = "#4b67b9", "Social Presence" = "#d85341", "Web Design" = "#ff8b24", "Web Development" = "#aad32e", "Website Content" = "#fec52e")
, breaks = sort(unique(statistics_data$Category))
, labels = sort(unique(statistics_data$Category_name))
) +
scale_y_continuous(breaks = NULL) +
coord_polar(theta="y") +
labs(fill = 'Ranking Factor Category', x = NULL, y = NULL)
使用ggsave
保存馅饼图表:
ggsave("test_pie_chart.svg", width = 5, height = 3, dpi = 300, bg = "transparent")
然后将svg嵌入html文件which can be downloaded here。
svg周围有边框!我如何摆脱它?