如何在 R 中的绘图中添加图形的名称?

How do I add the names of the graphs inside the plot in R?

我构建了图表,但我尝试添加图表的名称,但它不起作用。应该是图片里的样子,我只有图没有名字

如果有人知道应该使用哪个函数我会很高兴

geomtextpath 包看起来是这个用例的理想选择。也很好。

library(ggplot2)
library(geomtextpath)


ggplot(data.frame(x = 0)) +
  geom_textpath(stat = "function", fun = ~ 2.5 * .x,
                label = "Holding Cost",
                vjust = 1.1, colour = "green", hjust = 0.95, size = 6) +
  geom_textpath(stat = "function", fun = ~ 500 / .x ^0.5,
                label = "Set Up Cost",
                vjust = -0.1, colour = "blue", hjust = 0.95, size = 6) +
  geom_textpath(stat = "function", fun = ~ 500 / .x ^0.5 + 2.5 * .x,
                label = "Total Cost",
                vjust = -0.1, colour = "red", hjust = 0.95, size = 6) +
  xlim(1, 100)+
  theme_bw()

reprex package (v2.0.1)

于 2022-03-24 创建