R 不带y变量的ggplot图
如何使用ggplot创建一个数字线型图,其中的点具有不同的颜色和大小,以表示不同的变量?我试过这个:R 不带y变量的ggplot图,r,ggplot2,R,Ggplot2,如何使用ggplot创建一个数字线型图,其中的点具有不同的颜色和大小,以表示不同的变量?我试过这个: ggplot(data=data, aes(x=x, fill=fill, size=size)) + geom_point() 但我得到了以下错误: Error in as.environment(where) : 'where' is missing 我不知道那是什么意思。有没有办法做到这一点?主要有两个步骤:为y创建一个虚拟变量并删除y轴,如中所示 之后,它将处理您的图形高度和宽度,以
ggplot(data=data, aes(x=x, fill=fill, size=size)) + geom_point()
但我得到了以下错误:
Error in as.environment(where) : 'where' is missing
我不知道那是什么意思。有没有办法做到这一点?主要有两个步骤:为y创建一个虚拟变量并删除y轴,如中所示
之后,它将处理您的图形高度和宽度,以确保没有多余的空白。geom_point用于创建散点图,当您有两个变量时。我不知道你想做什么。你能举个例子吗?根据描述,我也不确定你想做什么。如果一个点不是二维的,怎么可能有一个点呢?有一个x位置和一个y位置?也许可以尝试qplot,看看默认的美学是否是您想要的。
library(tidyverse)
mtcars %>%
rownames_to_column() %>%
# Dummy variable
add_column(y = 0) %>%
ggplot(aes(x = mpg, y = y, label = rowname)) +
geom_point() +
geom_text(hjust = 'left', angle = 80, size = 2) +
# Make sure line is on the bottom
ylim(0, 0.1) +
# Remove axis lines and everything on y-axis
theme_classic() +
theme(axis.title.y =element_blank(),
axis.text.y = element_blank(),
axis.ticks.y=element_blank(),
axis.line = element_blank()) +
# Add number line
geom_hline(yintercept = 0) +
labs(title = 'Ranking by MPG')