0

I want to compare with the case where I do not categorize my data.

I can do

ggplot(dataset)+
    geom_boxplot(aes(x=Category, y=Values,fill = Category))

and I also can do

ggplot(dataset)+
    geom_boxplot(aes(y=Values))

But how can I display them combined in only one ggplot?

So x-axis would have labels like "Category A", "Category B", "Total".

Luan Vieira
  • 117
  • 1
  • 10
  • 1
    Try `facet_grid`, also from the `ggplot2` library. – bob1 Apr 18 '19 at 22:23
  • 1
    For a different style of solution using `facet_grid(..., margins=TRUE)`, try this: `ggplot(iris, aes(x=Species, y=Petal.Length)) + geom_boxplot() + facet_grid(. ~ Species, space="free", scales="free", margins=TRUE)` – bdemarest Apr 19 '19 at 03:28
  • 1
    By the way, the linked duplicate question does not specifically answer the OPs request "But how can I display them combined in only one ggplot?". – bdemarest Apr 19 '19 at 03:30

0 Answers0