rggplot2themesiris-dataset

View bar / texte d'axe / étiquettes tags with theme_void r


I made a graph on the iris database like this :

enter image description here

here's the code that allowed me to get this graph :

    library(tidyverse)
iris %>%
  gather("Type", "Value",-Species) %>%
  ggplot(aes(Species, Value, fill = Type)) +
  geom_bar(position = "dodge", stat = "identity") +
  theme_bw()+
  scale_fill_brewer(palette="Paired")+
  theme_void()+
  theme(legend.position = "right",
        legend.title = element_blank(),
        legend.text = element_text(size = 13))

And I used the theme_void to have a graph with a white background and without the lines axes. But it removes the labels of the three species (Verginica, Setosa...).

how I could display at the bottom of each group of bars the labels.

the other themes proposed by R don't suit me.

Thanks in advance


Solution

  • Just add this back to theme!

    library(tidyverse)
    iris %>%
      gather("Type", "Value",-Species) %>%
      ggplot(aes(Species, Value, fill = Type)) +
      geom_bar(position = "dodge", stat = "identity") +
      theme_bw()+
      scale_fill_brewer(palette="Paired")+
      theme_void()+
      theme(legend.position = "right",
            legend.title = element_blank(),
            legend.text = element_text(size = 13), 
            axis.title.x = element_text(),
            axis.text.x = element_text())
    

    Created on 2021-03-18 by the reprex package (v1.0.0)