基部图形可以用一个简单的命令如何在不指定x轴的情况下绘制箱形图?
data(mtcars)
boxplot(mtcars$mpg)
但是qplot
需要Y轴很好地绘制的箱线图。我怎样才能实现与qplot相同的基本图形boxplot而不会得到这个错误?
qplot(mtcars$mpg,geom='boxplot')
Error: stat_boxplot requires the following missing aesthetics: y
基部图形可以用一个简单的命令如何在不指定x轴的情况下绘制箱形图?
data(mtcars)
boxplot(mtcars$mpg)
但是qplot
需要Y轴很好地绘制的箱线图。我怎样才能实现与qplot相同的基本图形boxplot而不会得到这个错误?
qplot(mtcars$mpg,geom='boxplot')
Error: stat_boxplot requires the following missing aesthetics: y
您还可以使用latticeExtra
,混合boxplot
语法和ggplot2-like
主题:
bwplot(~mpg,data =mtcars,
par.settings = ggplot2like(),axis=axis.grid)
你可以设置x美学factor(0)
并通过除去不需要调整标签的外观:
ggplot(mtcars, aes(x = factor(0), mpg)) +
geom_boxplot() +
scale_x_discrete(breaks = NULL) +
xlab(NULL)
虽然这可能会回答这个问题,但请解释您的答案并可能会显示一个示例图像 – loki 2017-08-10 06:54:47
我明白了。所以qplot应该是qplot(factor(0),mtcars $ mpg,geom ='boxplot') – userJT 2013-02-22 16:37:17