graphique Barres avec ET et moyenne par classe

Postez ici vos questions, réponses, commentaires ou suggestions - Les sujets seront ultérieurement répartis dans les archives par les modérateurs

Modérateur : Groupe des modérateurs

margot julien
Messages : 46
Enregistré le : 28 Nov 2017, 12:10

graphique Barres avec ET et moyenne par classe

Messagepar margot julien » 15 Juil 2019, 08:46

Bonjour,

je cherche à faire un graphique "sympa" en barplot sur R. Je cherche à faire 2 types de graphiques:

graphique 1:
pour la variété var 1:
une moyenne +- écart type des 3 "années" du poids des racines en fonction des différents "Traitement", avec ou sans "field.treatment (yes/no)" et de mettre ceci pour 3 séries de données "période" = 3, 5 et 7 months. Peut-être avec 3 couleurs différentes pour les 3 périodes et des remplissage (rayé ou non" différents pour le yes ou no du field.treatment?

C'est facile sur excel mais est-ce possible sur R? si quelqu'un trouve un moyen de faire cela ça serait génial :) auriez-vous un code à me donner SVP? mon fichier est ci-dessous.

le deuxième type de graphique que j'aimerais faire c'est exactement la même chose mais pour les 5 variétés préalablement moyennées en gardant des barres avec une moyenne et un ecart-type des 3 années.

Merci par avance.


Code : Tout sélectionner

> dput(fi)
structure(list(ID = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L,
37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L,
63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L,
76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L,
89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L,
101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L,
112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L,
17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L,
30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 42L,
43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 55L,
56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 68L,
69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L, 78L, 79L, 80L, 81L,
82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L, 90L, 91L, 92L, 93L, 94L,
95L, 96L, 97L, 98L, 99L, 100L, 101L, 102L, 103L, 104L, 105L,
106L, 107L, 108L, 109L, 110L, 111L, 112L, 113L, 114L, 115L, 116L,
117L, 118L, 119L, 120L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L,
24L, 25L, 26L, 27L, 28L, 29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L,
37L, 38L, 39L, 40L, 41L, 42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L,
50L, 51L, 52L, 53L, 54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L,
63L, 64L, 65L, 66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L,
76L, 77L, 78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L,
89L, 90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L, 100L,
101L, 102L, 103L, 104L, 105L, 106L, 107L, 108L, 109L, 110L, 111L,
112L, 113L, 114L, 115L, 116L, 117L, 118L, 119L, 120L), Variete = structure(c(1L,
1L, 1L, 2L, 2L, 2L, 3L,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L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L), .Label = c("0month", "3months",
    "5months", "7months"), class = "factor"), Traitement = structure(c(1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
    3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
    4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
    2L, 2L, 2L, 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, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L,
    1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L,
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("No",
    "Yes"), class = "factor"), poids_racines = c(20, 103, 38,
    77, 153, 133, 190, 159, 183, 78, 134, 64, 166, 130, 126,
    5, 13, 5, 97, 17, 23, 83, 16, 41, 2, 19, 31, 1, 29, 14, 74,
    44, 12, 11, 100, 129, 93, 126, 158, 22, 61, 43, 1, 46, 76,
    154, 25, 25, 1, 1, 21, 110, 4, 8, 176, 39, 25, 1, 2, 12,
    3, 8, 8, 1, 1, 5, 33, 1, 2, 10, 1, 2, 4, 1, 3, 56, 1, 4,
    1, 1, 4, 17, 1, 5, 1, 2, 2, 1, 1, 4, 1, 50, 6, 168, 150,
    36, 106, 160, 36, 35, 69, 25, 25, 99, 42, 7, 1, 6, 102, 2,
    2, 60, 2, 1, 1, 3, 6, 26, 12, 6, 189, 120, 192, 179, 186,
    114, 94, 139, 112, 149, 144, 96, 123, 138, 84, 36, 135, 63,
    116, 57, 54, 164, 59, 71, 1, 194, 62, 1, 60, 48, 87, 170,
    54, 169, 111, 171, 136, 197, 172, 1, 157, 109, 1, 104, 128,
    125, 58, 45, 152, 11, 20, 140, 7, 53, 118, 131, 34, 1, 7,
    32, 1, 36, 1, 1, 9, 1, 24, 18, 1, 1, 15, 1, 1, 15, 1, 1,
    1, 3, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 4, 1, 152, 28, 124,
    121, 18, 155, 91, 7, 72, 73, 2, 126, 85, 17, 101, 25, 1,
    113, 1, 1, 62, 10, 1, 1, 30, 1, 71, 61, 1, 195, 182, 146,
    117, 95, 163, 185, 175, 165, 79, 80, 142, 199, 188, 115,
    32, 65, 151, 147, 107, 105, 89, 66, 51, 23, 81, 167, 20,
    67, 196, 180, 143, 193, 2, 82, 90, 161, 181, 198, 1, 200,
    190, 1, 173, 169, 184, 108, 88, 92, 52, 32, 174, 50, 21,
    178, 145, 127, 122, 47, 13, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 37, 1, 1, 1, 1, 4, 1, 1,
    1, 132, 191, 27, 86, 187, 49, 68, 137, 28, 148, 190, 8, 162,
    119, 8, 128, 156, 70, 141, 1, 1, 177, 55, 1, 1, 98, 26, 1,
    75, 1), taille_racines = c(140, 77, 187, 98, 109, 228, 93,
    245, 108, 113, 243, 204, 102, 88, 238, 15, 44, 30, 236, 58,
    69, 123, 136, 142, 34, 153, 148, 16, 138, 63, 202, 190, 68,
    36, 219, 226, 119, 230, 221, 66, 201, 178, 1, 189, 210, 233,
    20, 82, 45, 27, 40, 117, 33, 50, 97, 185, 57, 3, 31, 52,
    25, 39, 32, 14, 27, 28, 133, 29, 24, 45, 23, 20, 27, 25,
    21, 83, 9, 20, 23, 22, 28, 62, 14, 25, 19, 31, 31, 15, 14,
    22, 1, 152, 32, 232, 93, 138, 188, 244, 68, 134, 212, 58,
    177, 242, 185, 5, 19, 38, 203, 30, 25, 133, 12, 26, 3, 37,
    33, 44, 140, 41, 116, 121, 99, 206, 197, 156, 107, 120, 125,
    196, 157, 114, 174, 171, 118, 132, 207, 150, 126, 151, 145,
    194, 87, 155, 27, 240, 198, 23, 191, 147, 96, 231, 144, 179,
    100, 235, 130, 89, 227, 25, 209, 208, 23, 202, 216, 129,
    131, 146, 61, 30, 75, 121, 35, 148, 115, 200, 81, 27, 45,
    143, 27, 144, 27, 13, 27, 27, 141, 72, 27, 17, 44, 27, 14,
    36, 27, 19, 17, 32, 15, 23, 27, 22, 23, 33, 27, 25, 28, 25,
    25, 31, 16, 229, 59, 110, 128, 78, 180, 90, 45, 176, 211,
    33, 220, 95, 132, 64, 62, 27, 104, 27, 27, 139, 39, 27, 19,
    66, 27, 78, 72, 27, 223, 170, 165, 106, 225, 192, 214, 168,
    161, 246, 213, 164, 224, 172, 122, 39, 80, 184, 111, 84,
    149, 234, 48, 77, 42, 215, 205, 40, 49, 135, 167, 160, 241,
    23, 195, 91, 158, 159, 239, 25, 193, 237, 20, 163, 218, 162,
    154, 92, 217, 51, 70, 124, 54, 55, 166, 105, 182, 188, 53,
    43, 25, 71, 27, 19, 27, 26, 20, 53, 15, 22, 56, 27, 19, 27,
    27, 22, 76, 28, 22, 16, 24, 33, 27, 22, 25, 49, 34, 22, 46,
    27, 186, 103, 65, 222, 169, 183, 71, 94, 86, 173, 101, 54,
    175, 112, 60, 137, 85, 199, 127, 25, 27, 181, 47, 27, 27,
    73, 67, 229, 84, 27)), row.names = 31:390, class = "data.frame")

Mickael Canouil
Messages : 1315
Enregistré le : 04 Avr 2011, 08:53
Contact :

Re: graphique Barres avec ET et moyenne par classe

Messagepar Mickael Canouil » 16 Juil 2019, 15:07

Bonjour,

voici une proposition avec le tidyverse

Code : Tout sélectionner

library(tidyverse)

data_mean_se <- fi %>%
  group_by(Traitement, periode, field.treatment) %>% # group the data according to the variables
  summarise_at(vars(poids_racines), .funs = ~list(mean_se(.x))) %>% # summarise the values of "poids_racines" using mean and se, i.e., compute mean as "y" and mean+se as "ymax" and mean-se as "ymin")
  unnest(poids_racines) %>%
  ungroup()
 
ggplot(
  data = data_mean_se,
  mapping = aes(
    x = Traitement,
    y = y, ymin = ymin, ymax = ymax,
    fill = periode,
    alpha = field.treatment
  )
) +
  geom_errorbar(mapping = aes(colour = periode), width = 0.45, position = position_dodge(width = 0.9)) +
  geom_bar(stat = "identity", position = position_dodge(width = 0.9)) +
  scale_alpha_manual(values = c(0.50, 1)) +
  labs(y = "poids_racines")

Image

Cordialement,
Mickaël
mickael.canouil.fr | rlille.fr

Fred Santos
Messages : 233
Enregistré le : 11 Avr 2009, 10:00
Contact :

Re: graphique Barres avec ET et moyenne par classe

Messagepar Fred Santos » 17 Juil 2019, 10:24

Jolie réponse technique de Mickael !

[HS]
Au passage, ce type de représentation graphique est assez fortement déconseillé (et est déjà interdit dans pas mal de revues scientifiques). Voir ici pour une illustration : https://garstats.wordpress.com/2016/07/ ... p-results/

Si la réponse de Mickael était parfaite, la question d'origine était donc discutable. ;-)
[/HS]

Mickael Canouil
Messages : 1315
Enregistré le : 04 Avr 2011, 08:53
Contact :

Re: graphique Barres avec ET et moyenne par classe

Messagepar Mickael Canouil » 17 Juil 2019, 10:48

Fred Santos a écrit :Jolie réponse technique de Mickael !

[HS]
Au passage, ce type de représentation graphique est assez fortement déconseillé (et est déjà interdit dans pas mal de revues scientifiques). Voir ici pour une illustration : https://garstats.wordpress.com/2016/07/ ... p-results/

Si la réponse de Mickael était parfaite, la question d'origine était donc discutable. ;-)
[/HS]


Je suis assez d'accord, personnellement j'aurai découpé en utilisant des "facets" selon les tests de comparaison à effectuer.

Code : Tout sélectionner

library(tidyverse)

data_mean_se <- fi %>%
  group_by(Traitement, periode, field.treatment) %>% # group the data according to the variables
  summarise_at(vars(poids_racines), .funs = ~list(mean_se(.x))) %>% # summarise the values of "poids_racines" using mean and se, i.e., compute mean as "y" and mean+se as "ymax" and mean-se as "ymin")
  unnest(poids_racines) %>%
  ungroup()
 
ggplot(
  data = data_mean_se,
  mapping = aes(
    x = Traitement,
    y = y, ymin = ymin, ymax = ymax
  )
) +
  geom_errorbar(width = 0.45, position = position_dodge(width = 0.9)) +
  geom_bar(stat = "identity", position = position_dodge(width = 0.9)) +
  scale_alpha_manual(values = c(0.50, 1)) +
  labs(y = "poids_racines") +
  facet_grid(rows = vars(periode), cols = vars(field.treatment))

Image

ou avec un peu moins de découpage, si on s’intéresse à chaque période

Code : Tout sélectionner

library(tidyverse)

data_mean_se <- fi %>%
  group_by(Traitement, periode, field.treatment) %>% # group the data according to the variables
  summarise_at(vars(poids_racines), .funs = ~list(mean_se(.x))) %>% # summarise the values of "poids_racines" using mean and se, i.e., compute mean as "y" and mean+se as "ymax" and mean-se as "ymin")
  unnest(poids_racines) %>%
  ungroup()
 
ggplot(
  data = data_mean_se,
  mapping = aes(
    x = Traitement,
    y = y, ymin = ymin, ymax = ymax,
    colour = field.treatment,
    fill = field.treatment
  )
) +
  geom_errorbar(width = 0.45, position = position_dodge(width = 0.9)) +
  geom_bar(stat = "identity", position = position_dodge(width = 0.9)) +
  scale_alpha_manual(values = c(0.50, 1)) +
  labs(y = "poids_racines") +
  facet_grid(cols = vars(periode))

Image
Mickaël
mickael.canouil.fr | rlille.fr


Retourner vers « Questions en cours »

Qui est en ligne

Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 1 invité