![]() ![]() We can use the data argument to add a geom_text() layer that uses the new dataset to position the cluster labels at the centre of each cluster. This dataset defines the centre of each cluster. ![]() Instead, we could add a layer based on another dataset.įor example, Cuddy et al. (2009) divided countries into three clusters: countries seen as low in competence and high in warmth ( LC-HW), countries seen as high in competence and low in warmth ( HC-LW), and countries seen as very high in competence and very low in warmth ( HHC-LLW). Still, this method gets cumbersome when we want to annotate more than two data points. This plot shows that ratings by the same group and other groups are a lot closer for the UK than for Belgium. ggplot(dl, aes(x = competence, y = warmth)) + We can use vectors, c(.), to annotate more than one point. ![]() We might want to highlight another data point. The vjust aesthetic specifies the vertical justification of the text relative to its x- y coordinates (see here for details). Note that geom_text() requires the label aesthetic in addition to the x and y aesthetics. This time, the annotate() layer creates a geom_text() layer. We could explain this in the plot’s caption, but it’d be easier for the reader if we included that information in the plot itself. This plot highlights Belgians’ ratings of how they thought Belgians were seen by others. Note that we have placed the annotate() layer below the geom_point() layer. It can take on the form of any other geom (in this case, geom = "point"). The annotate() function does not inherit aesthetics ( x, y) from the ggplot() function. We add an annotate() layer to highlight this data point. ![]() This, however, is difficult to tell from the plot. Belgians seem to think that other EU citizens see Belgians as a lot less warm. Overall, respondents tended to think that their own country was seen as warmer and more competent than respondents from other countries thought. We use now-familiar commands to compare how ratings by the same group and other groups differ. This plot shows that respondents rated only one country as both competent and warm (upper-right quadrant). If not, have a look at the other posts before reading on or use the help() function. Geom_vline(xintercept = 0.5, linetype = "dashed", colour = "grey20") +Ĭoord_fixed(1, xlim = c(0, 1), ylim = c(0, 1))Īll of this should be familiar by now. Geom_hline(yintercept = 0.5, linetype = "dashed", colour = "grey20") + We add geom_vline() to divide the plot into quadrants. In another post, we have already used geom_hline() to annotate a plot. It contains two ratings for countries that were represented among respondents, one by raters from the same country ( rater = "same") and one by raters from other countries ( rater = "other"). This dataset contains the aggregated competence and warmth ratings for each country. Students from seven EU nations (Belgium, France, Germany, the Netherlands, Portugal, Spain, and the UK) rated how competent and warm they thought each of fifteen EU nations (including their own) was perceived by other EU citizens. This week’s dataset comes from a study by Cuddy et al. (2009). If you haven’t yet, you first need to install the tidyverse package by running install.packages("tidyverse"). We begin by loading the tidyverse package which contains ggplot2 alongside other useful packages. This is the fifth of a series of posts on how to use ggplot2 to visualise data in R. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |