【发布时间】:2018-02-14 01:49:24
【问题描述】:
我在使用 geom_point 进行绘图时出错。
library(ggplot2)
theme_set(theme_bw())
mtcars$`car name` <- rownames(mtcars)
mtcars$mpg_z <- round((mtcars$mpg - mean(mtcars$mpg))/sd(mtcars$mpg), 2)
mtcars$mpg_type <- ifelse(mtcars$mpg_z < 0, "below", "above")
mtcars <- mtcars[order(mtcars$mpg_z), ] # sort
mtcars$`car name` <- factor(mtcars$`car name`, levels = mtcars$`car name`)
ggplot() +
geom_point(data=mtcars, aes(x=`car name`, y=mpg_z,label=mpg_z), stat='identity', fill="black", size=6) +
geom_text(color="white", size=2) +
labs(title="Diverging Lollipop Chart",
subtitle="Normalized mileage from 'mtcars': Lollipop") +
ylim(-2.5, 2.5) +
coord_flip()
但我无法在点内输入数字并出现错误:
Warning: Ignoring unknown aesthetics: label
【问题讨论】:
-
label是geom_text而不是geom_point的美学。 -
@dorayin 如果您找到了问题的解决方案,请接受其中一个答案 (stackoverflow.com/help/someone-answers),以便该线程不再处于活动状态。跨度>
标签: r