我有一个用ggplot2
创建的图表,并且我想使用CairoPNG
来创建,因为在创建饼图时,png
和jpeg
会产生非常像素化的图像。问题是CairoPNG
似乎会修改文本大小,因此,在图例中,一个键的文本会重叠到其他键上,或者像上面那样。
library(ggplot2)
library(Cairo)
df <- data.frame(id=c("IMPORT VALUES YTD", "EXPORT VALUE YTD"),
value=c(6,4))
chart <- ggplot(df) +
geom_bar(aes(x=factor(1), y=value, fill=factor(id)),
stat="identity", width = 1, color="white") +
coord_polar(theta="y") +
theme(legend.title=element_blank(),
legend.position="top",
legend.text=element_text(size=14))
CairoPNG("test1.png", 350, 400)
chart
dev.off()
png("test2.png", 350, 400)
chart
dev.off()
您知道如何避免这种情况吗?
注:该图片无法翻译。