Skip to content
What's New in R is a weekly email to help you up your R game. Sign up →
R for the Rest of Us Logo

Fundamentals of R

Plot Labels

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

Complete the plot labels sections of the data-visualization-exercises.Rmd file.

Learn More

Plot Labels Resources

Chapter 22 of Fundamentals of Data Visualization

Information about using position = "dodge" can be found on the tidyverse website. To see all position adjustments, check out the ggplot2 reference page.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Jodi Fender

Jodi Fender • April 13, 2021

I need to do some more googling, but am trying to figure out how to have labels center on the bars - like in your example here with 3 variables (age, height, gender). I have 2 variables each with two categories and a continuous "Score" but the score for both levels is showing up in the center of the two bars rather than on the center of EACH bar. Maybe this is hard to explain here. If I don't have time to figure it out AND my question isn't clear for you to answer here, I'll submit my with the weird bar labels for feedback. Second, when I try to apply the scale_y_continuous by bars keep disappearing. I can get it to work sometimes but then suddenly it stops plotting. I guess I'll post that on my GitHub submission too. Oh! Maybe when I get to facets, I can have small multiples and bypass the issue of the centered labels...haha. But I do want to figure it out for the future.

Jodi Fender

Jodi Fender • April 13, 2021

I got somewhere with the geom_text position related to the dodging! Learning how/what to google is exciting: geom_text(aes(label = mean_standard_score), position = position_dodge(width = 1), hjust = 1.5, color = "white")