我有以下代码:
library(ggplot2)
ggplot(cars, aes(x = speed, y = dist)) +
geom_line()
创建以下情节
我想要做的是将x轴(speed
)值5,10,15,20,25
替换为以下向量:c("-5000", "-2500", "FOO", "2500", "5000")
。
但为什么会失败?
ggplot(cars, aes(x = speed, y = dist)) + geom_line() +
scale_x_discrete(labels = c("-5000", "-2500", "TSS", "2500", "5000"))
它产生了这个:
这样做的正确方法是什么?