An example of barplot with ggplot2

 From R-help discussion list; answer by Rui Barradas. I like this answer and I copy it here:

h <- c(574,557,544,535,534,532,531,527,526,525, 
       524,520,518,512,507,504,504,489,488,488, 
       487,484,484,474,472,455,444,420) 

nms <- c("Fribourg(f)","Valais(d)","Appenzell Rhodes Intérieures", 
         "Fribourg(d)","Jura","Schwyz","Schaffhouse","Berne(f)", 
         "Thurgovie","Valais(f)","Argovie","Appenzell Rhodes Extérieures", 
         "Genève","Zoug","Tessin","Neuchâtel","Vaud","Uri","Nidwald", 
         "Berne(d)","Zurich","Obwald","Saint-Gall","Soleure","Lucerne", 
         "Glaris","Bâle-Campagne","Bâle-Ville") 
nms <- factor(nms, levels = nms) 

library(ggplot2) 

data.frame(height = h, names = nms) |> 
  ggplot(aes(names, height)) + 
  geom_col(fill = "deepskyblue2") + 
  coord_flip() + 
  theme_classic() + 
  theme(axis.text.y = element_text(face = "italic"))

Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04