我同意这样的评论,即可能造成混淆或误导,因为连接分类变量会暗示可能是主观或误导的频谱和间距。
但是,假设这对您的用例有意义,则可以通过以下方式解决此问题:将要素转换为数字化,连续的“后台数据”,然后将标签调整为分类类型。例如:
mtcars %>%
mutate(gear = as.factor(gear)) %>%
group_by(gear) %>%
summarise(mpg = mean(mpg)) %>%
mutate(factor_num = as.numeric(gear)) -> temp
ggplot(temp, aes(x = factor_num, y = mpg)) +
# This geom draws a smooth line through your points
ggalt::geom_xspline(spline_shape = -0.5) +
geom_point() +
scale_x_continuous(breaks = temp$factor_num, labels = temp$gear, name = "gear") +
expand_limits(y = 0)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句