How to create alternating background colors in R with ggplot2 (CC137)

preview_player
Показать описание
Putting rectangles with alternating colors in the background of a figure is not obvious in R. But if you implement these colored strips, they can be an attactive way to repalce gridlines. The alternating colored strips can help your audience see what data go together. In this episode of Code Club, Pat will morph a figure he made that was originally creaed by Ipsos to a more stylized one published by chartr. The data depict the percentage of people in 15 countries who would be willing to receive the COVID-19 vaccine as of August and October of 2020.

You can also find complete tutorials for learning R with the tidyverse using...

0:00 Introduction
6:40 Use geom_ribbon to create colored background strips
11:49 Represent three different colors in strips
14:48 Convert y-axis from plotting discrete to continuous values
17:21 Remove extra padding between axes and axis labels
18:19 Put y-axis tick marks between country names
21:59 Recap
Рекомендации по теме
Комментарии
Автор

chartr is one of several data-rich newsletters that I subscribe to (see the link in the description. Where do you go to find data visualizations that inspire you?

Riffomonas
Автор

Before I watch the rest of the video, I just wanted to say that these tutorials are fantastic, great explanation. Always helping expanding my r knowledge. Thanks a lot .

mahmudurrahman
Автор

This is helpful. I’m looking forward to the rest of the plot customization.

russtin
Автор

Just learned how to fix a problem in a different plot I made for publication and had to do in adobe. Changing the y axis to have discreet names and not the continuous values used to make the plot. Very helpful.

geridollison
Автор

Here’s a topic I’d like to see, mainly as I’m struggling with it myself. How to design a properly powered experiment using microbiome data. Based on spare pilot data how would you generate a power calculation from say a permanova type analysis?

JimtheEvo
Автор

plot +
scale_fill_manual(name = NULL,
breaks = c("a", "b", "c"),
values = c("strangegray", "strangeblue", "headerblue"))

But we are still missing the arrows,
Therefore, we could introduce the geom_segment()
Where we could calculate the mean between the % of the changes and use this as anchor point - which will automatically show us an increase or decrease

geom_segment(aes(x = percent , y = y_position, xend = meanofpercers, yend = y_position))

svenr
join shbcf.ru