Get access to all lessons in this course.
-
RMarkdown
- Why Use RMarkdown?
- RMarkdown Overview
- YAML
- Text
- Code Chunks
- Wrapping Up
-
Data Wrangling and Analysis
- Getting Started
- The Tidyverse
- select
- mutate
- filter
- summarize
- group_by
- count
- arrange
- Create a New Data Frame
- Crosstabs
- Wrapping Up
-
Data Visualization
- An Important Workflow Tip
- The Grammar of Graphics
- Scatterplots
- Histograms
- Bar Charts
- color and fill
- scales
- Text and Labels
- Plot Labels
- Themes
- Facets
- Save Plots
- Wrapping Up
-
Wrapping Up
- You Did It!
Fundamentals of R
Plot Labels
This lesson is locked
This lesson is called Plot Labels, part of the Fundamentals of R course. This lesson is called Plot Labels, part of the Fundamentals of R course.
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.
You need to be signed-in to comment on this post. Login.
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
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")
David Keyes
April 13, 2021
Yes, that's exactly where I got to in the end! I think we both ended up on the same Stack Overflow thread. I have to be honest and say I'm not super solid in my understanding of the width argument on the
position_dodge()
function, but it works!Jodi Fender
April 13, 2021
Similar, I think! Thanks! https://stackoverflow.com/questions/44818459/plot-text-labels-centered-on-a-dodged-bar-plot