我在输出到pdf时试图摆脱geom_label创建的边框.设置lable.size = 0似乎在输出到png时或仅在R会话中的绘图窗口中有效但在输出到pdf时边界仍然存在.我喜欢geom_label over geom_text,因为背景使得当绘图上有线条时更容易阅读.由于我正在使用后者的情节,所以我更容易获得pdf输出,所以如果有人知道如何摆脱那将是伟大的边界.
我目前在Mac OS Sierra上使用ggplot 2.2.1和R 3.3.3.下面是一些示例代码.
require(ggplot2)
#no border
ggplot(data.frame(nums = 1:10), aes(x =nums, y = nums) ) +
geom_point() +
geom_label(label = "italic(R) ^ 2 == .87", label.size = 0, x = 2, y = 8, vjust = "inward", hjust = "inward", parse = T) +
theme_bw()
pdf("testPlot.pdf")
#border appears in pdf
print(ggplot(data.frame(nums = 1:10), aes(x =nums, y = nums) ) +
geom_point() +
geom_label(label = "italic(R) ^ 2 == .87", label.size = …Run Code Online (Sandbox Code Playgroud)