The base graphics can nicely plot a boxplot using a simple command
data(mtcars)
boxplot(mtcars$mpg)
You have to provide some dummy value to x
. theme()
elements are used to remove x axis title and ticks.
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())
Or using qplot()
function:
qplot(factor(0),mpg,data=mtcars,geom='boxplot')