基部圖形可以用一個簡單的命令如何在不指定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