答案 0 :(得分:1)
您可以执行以下操作:
my_func <- function(x) x / (x - 1) - 2
library(ggplot2)
ggplot(data.frame(x = 0), aes(x)) +
stat_function(fun = my_func, aes(colour = "Function")) +
geom_hline(aes(yintercept = -1, colour = "Asymptote")) +
scale_colour_manual(values = c("Asymptote" = "blue", "Function" = "orange")) +
xlim(-10, 10) +
theme_minimal()