基本图形可以使用简单的命令很好地绘制箱线图
data(mtcars)
boxplot(mtcars$mpg)
Run Code Online (Sandbox Code Playgroud)

但qplot需要y轴.我如何实现与qplot相同的基本图形boxplot并没有得到这个错误?
qplot(mtcars$mpg,geom='boxplot')
Error: stat_boxplot requires the following missing aesthetics: y
Run Code Online (Sandbox Code Playgroud)
Did*_*rts 17
你必须提供一些虚拟值x.theme()元素用于删除x轴标题和刻度.
ggplot(mtcars,aes(x=factor(0),mpg))+geom_boxplot()+
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank())
Run Code Online (Sandbox Code Playgroud)
或使用qplot()功能:
qplot(factor(0),mpg,data=mtcars,geom='boxplot')
Run Code Online (Sandbox Code Playgroud)