Reputation: 31
I have a dataset with four categories of vowel, akin to the following:
speaker vowel_category f1 f2
1 a x x
1 b x x
1 c x x
1 d x x
2 a x x
2 b x x...
This geom_point code plots them all one one graph with stat_ellipse and is 90% what I need:
ggplot(data = topicsubset_ikf, aes(x = F2, y = F1, shape = CATEGORY)) +
geom_point() +
scale_y_reverse() +
scale_x_reverse() +
xlab("F2") +
ylab("F1") +
labs(title = "All speakers with KIT and FLEECE tokens") +
coord_cartesian(xlim = c(1.9, 1.1), ylim = c(0.3, 1.5)) +
facet_wrap(~ SPEAKER) +
scale_color_manual(values = c("#000000", "#FF8F00", "#000000", "#A200FF")) +
stat_ellipse(geom = "polygon", alpha = 1 / 2, aes(fill = CATEGORY))
However, it would be ideal if I could draw ellipses round just two of the four categories (say, a and b), rather than all 4, so I can look at the spread of c & d relative to a and b. I haven't been able to find a way so far - I've tried combining multiple datasets on one graph to no avail. Any suggestions?
Upvotes: 3
Views: 1686
Reputation: 11
I had the same problem, I found that now you can just specify the group in stat_ellipse like this:
stat_ellipse(geom = "polygon", alpha = 1 / 2, aes(fill = CATEGORY, group = CATEGORY))
Upvotes: 1