1

I found similar questions (with answers), but since I'm a novice in R (and programming) I was not able to do it. Plus, I would like to find a way to calculate the area of all 40 ellipses at once (with appropriate label, in this case, the vowel, condition and group)... I feel like I'm asking too much! hahaha

Here's the code for my plot ... I fell you'll might need my data as well, but I don't know how to share it (sorry!)

ggplot(Acoustique, aes(x=F2Z, y= F1Z, label=Voyelle, color=Condition))+
  geom_text(aes(label=Voyelle, color=Condition))+
  scale_color_brewer(palette="Paired") +
  stat_ellipse(aes(x=F2Z, y=F1Z, group=GrCondVoy), type = "norm") +
  scale_x_reverse()+
  scale_y_reverse()+
  facet_wrap(~ Groupe)

Many many thanks, Have a good day!

EDIT :

I've created a sample version of my data.

Here it is:

structure(list(Groupe = c("A", "A", "A", "A", "A", "A", "A", 
"A", "A", "A", "A", "A", "A", "A", "A", "C", "C", "C", "C", "C", 
"C", "C", "C", "C", "C", "C", "C", "C", "C", "C", "C"), Sujet = c("A1", 
"A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", "A1", 
"A1", "A1", "A1", "C1", "C1", "C1", "C1", "C1", "C1", "C1", "C1", 
"C1", "C1", "C1", "C1", "C1", "C1", "C1", "C1"), Condition = c("A", 
"A", "A", "A", "A", "A", "A", "A", "AB", "AB", "AB", "AB", "AB", 
"AB", "AB", "A", "A", "A", "A", "A", "A", "A", "A", "AB", "AB", 
"AB", "AB", "AB", "AB", "AB", "AB"), Voyelle = c("3", "3", "3", 
"3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "a", 
"a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", 
"a", "a"), Répétition = c(1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 
5, 6, 7, 1, 2, 3, 4, 5, 6, 7, 8, 1, 4, 8, 2, 3, 5, 6, 7), F1 = c(558.415760287863, 
566.796625078936, 532.863704118383, 571.318024130525, 539.654990789293, 
607.323680383953, 551.962323861051, 591.236665628275, 557.085142851998, 
525.14785411208, 532.476098051716, 554.196511159636, 589.050398911367, 
565.977645601874, 588.111378126528, 765.563228246044, 675.36616009505, 
780.4246824951, 779.394963149183, 791.086032826099, 706.680534665576, 
712.451146327484, 765.375314530951, 789.595553741084, 758.02685327701, 
758.78855746202, 750.207206155362, 791.615430184283, 749.906581896308, 
762.984312561331, 751.559088887048), F2 = c(2180.59281382346, 
2192.20950386395, 2207.67322220816, 2234.49073527147, 2207.93387149726, 
1806.89333562128, 2222.5316488558, 1867.18086902399, 1968.45894616977, 
2069.77988096485, 2030.39405875941, 1990.3334984054, 1992.16714949532, 
2080.5088337103, 2042.7505719158, 1311.05329884053, 1439.85802779364, 
1434.43056795057, 1319.89042783658, 1281.66303440129, 1408.87918405377, 
1421.3724185324, 1307.84200656912, 1265.34289592884, 1348.16860516254, 
1383.54554975986, 1271.54316804908, 1295.14865025929, 1314.93853220485, 
1326.02956353481, 1313.68215853299), GrCondVoy = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L), .Label = c("A A 3", 
"A AB 3", "C A a", "C AB a"), class = "factor")), row.names = c(NA, 
-31L), class = c("tbl_df", "tbl", "data.frame"))

and here's the code for the ''sample'' plot:

ggplot(Acoustique_sample, aes(x=F2, y= F1, label=Voyelle, color=Condition))+
  geom_text(aes(label=Voyelle, color=Condition))+
  scale_color_brewer(palette="Paired") +
  stat_ellipse(aes(x=F2, y=F1, group=GrCondVoy), type = "norm") +
  scale_x_reverse()+
  scale_y_reverse()+
  facet_wrap(~ Groupe)

Here is the ''sample'' plot

Let's hope it will help!

pmtf
  • 11
  • 2
  • Hi pmtf, welcome to Stack Overflow. It will be much easier to help if you provide at least a sample of your data with `dput(Acoustique[1:20,])`. You can [edit] your question and paste the output. Please surround the output with three backticks (```) for better formatting. See [How to make a reproducible example](https://stackoverflow.com/questions/5963269/) for more info. – Ian Campbell Jun 18 '20 at 20:18
  • See also https://stackoverflow.com/questions/38782051/how-to-calculate-the-area-of-ellipse-drawn-by-ggplot2 – erocoar Jun 18 '20 at 20:39
  • Ian Campbell - I did I did what you asked now ;) – pmtf Jun 18 '20 at 20:49

0 Answers0