

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") +

ggplot(dl, aes(x = competence, y = warmth)) + 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).
#Ggplot annotate text install
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. Mapping = aes(x = x, y = y, label = label), Penguins %>% ggplot( aes(x = flipper_length_mm, y = body_mass_g, colour = species)) + geom_point() + scale_colour_hp_d(option = "LunaLovegood") + geom_text(data = ame(x = 188.437797399636, y = 5990.9008070379, label = "Gentoo penguins are much larger"), Remotes::install_github("mattcowgill/ggannotate")
#Ggplot annotate text code
You can install the package from github using this line of code I shared this post on Twitter and within a few minutes Matt Cowgill let me know that he has been working on a package called ggannotate which lets you add notes and arrows to your ggplot, using a point and click interface via a Shiny app. One of the best things about blogging about what you learn is that you can give it away and then people let you know about new/different/easier ways to do what you just learned to do.

Penguins %>% ggplot( aes(x = flipper_length_mm, y = body_mass_g, colour = species)) + geom_point() + annotate( "text", x = 180, y = 6000, label = "Gentoo penguins \n are much larger") + annotate( "text", x = 223, y = 3000, label = "It is hard to differentiate \n Chinstrap and Adelie") + geom_curve(ĭata = arrows, aes(x = x1, y = y1, xend = x2, yend = y2),Īrrow = arrow(length = unit( 0.08, "inch")), size = 0.5,Ĭolor = "gray20", curvature = -0.3) + scale_colour_hp_d(option = "LunaLovegood")
