@rappa753
Albert Rapp
3 years
Everybody loves colors but only few know how to use them well. With the right guidelines, using colors becomes super easy. Let me show you how to implement these guidelines with ggplot 🧡 #rstats
4
44
168

Replies

@rappa753
Albert Rapp
3 years
Anyone can create a stacked bar chart with ggplot. But that can end up in a colorful & messy plot. Let's implement a couple of guidelines from this datawrapper blog post to level up our color game https://t.co/oxH1EXBATU
1
1
15
@rappa753
Albert Rapp
3 years
The key is to reduce the amount of colors and leverage the `alpha` aesthetic as well.
1
0
12
@rappa753
Albert Rapp
3 years
Once you have fewer colors. You can concentrate on a better choice. How about the color-blind safe okabe ito palette? While you're at it. How about a better range of `alpha` values so that top and bottom blocks have the same transparency?
1
0
7
@rappa753
Albert Rapp
3 years
Now comes the hard part. Consolidate the two legends into one. Overwriting the aesthetics in a guides() layer will do the trick.
1
1
10
@rappa753
Albert Rapp
3 years
There you go. Same information as in the beginning but less of a rainbow mess. 🌈 Still it would be nice to make adjacent blocks stand out. No problem. Use the `color` aesthetic to add lines. But wait. There is more πŸ₯³
2
1
7
@rappa753
Albert Rapp
3 years
Spaghetti plots are easy to create but hard to decipher. This is a chance to shine for the {gghighlight} package.
1
2
9
@rappa753
Albert Rapp
3 years
{gghighlight} makes it dead-simple to emphasize parts of your plot. And with a small annotation, we can immediately tell a story.
1
1
14
@rappa753
Albert Rapp
3 years
Of course, this also works with more than just one color. Once we get rid of too many colors, why not also get rid of other clutter like the legend?
1
1
7
@rappa753
Albert Rapp
3 years
That's some efficient use of space and colors right there! Finally, let's come full circle and apply the same labeling techniques to our initial bar plot.
1
0
7
@rappa753
Albert Rapp
3 years
That's a wrap πŸ₯³ For the full code and more explanations, check out my blog post at https://t.co/CcCJwHH0MV Let me know if you enjoyed this thread, by hitting the like button on the start of this thread below. ☺️ For more posts like this, follow @rappa753 See you next time πŸ‘‹
@rappa753
Albert Rapp
3 years
Everybody loves colors but only few know how to use them well. With the right guidelines, using colors becomes super easy. Let me show you how to implement these guidelines with ggplot 🧡 #rstats
2
3
12
@rappa753
Albert Rapp
3 years
If you liked this post, you may enjoy my 3-minute newsletter too. Every week, my newsletter shares insights on - R & dataviz, - Shiny and web dev Reading time: 3 minutes or less You can join at https://t.co/GePE370FdL
0
0
1
@MartinOnData
MartinOnData
3 years
@rappa753 Love the gghighlight tip!
0
0
1
@cordura21
cordura21
3 years
@rappa753 Excellent
0
0
1