如何在用户坐标中的ggplot2图形上获得字符流的高度和宽度?

时间:2019-04-28 23:46:22

标签: r ggplot2 character size

在用户坐标中查找字符流的高度和宽度。

library (ggplot2)
ggplot_build(figure)

似乎没有帮助

我正在使用annotate("text", label = ...) RStudio中的简单示例代码:

    x_pts <- c(1,2,3,4,5)
    y_pts <- c(1,2,3,4,5)
    df <- data.frame(x_pts, y_pts)
    ggp <- ggplot(data = df, aes(x_pts, y_pts))
    ggp <- ggp + geom_point(size = 1, color = "blue")
    ggp <- ggp + annotate("text", x = 3, y = 4, label = "Data Points",    color = "black")
    print(ggp)

结束示例代码。我希望在绘图上的用户坐标中找到字符流“数据点”的长度和宽度。我计划对注释进行一些操作,例如选择一种字体大小,以使其在图形上占据特定区域。

0 个答案:

没有答案