我想导出在ggplot2
中生成的图像的SVG。
我尝试重新安装并安装svglite
并使用dependencies = TRUE
进行安装,但是仍然遇到相同的错误。
我正在使用ggplot2
,reshape
和svglite
:
library(ggplot2)
library(reshape2)
library(svglite)
我生成了一个包含图像的变量:
image = ggplot(new.df) + geom_tile(aes(x=algorithm, y=name, fill=solved == "0")) + scale_x_discrete("") +
scale_y_discrete(limits = rev(levels(df$name))) + scale_fill_manual(values = c("#33DD33", "#DD3333"), na.value="gray50") +
theme(axis.text.x = element_text(angle = 90), legend.position="none")
然后执行以下行:
ggsave(file='~/Desktop/eterna100_51-100_ordered_TEST.svg', plot=image, device = "svg")
但是,出现此错误:
Error: package or namespace load failed for ‘svglite’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/gdtools/libs/gdtools.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/gdtools/libs/gdtools.so, 6): Library not loaded: /opt/X11/lib/libcairo.2.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/gdtools/libs/gdtools.so
Reason: image not found