Albert Rapp Profile picture
🎓 Math PhD student & freelancer 👨‍🏫 Bite-sized insights on dataviz, web dev & data science with R at https://t.co/M34b5BzHTD

Aug 11, 2022, 9 tweets

Forget regular heat maps. Use bubbles on a grid instead 🔵 🟢 🤯

A short #dataviz thread 🧵 🧵

#rstats #ggplot2

1/8

Regular heat maps have the crucial flaw of not showing how much samples were used. 🤔

That's totally fine when the different sizes are shown (e.g. with colors). It's what I did with my calendar plot a while back (special heat map)


2/8

But look what happens when I use a color gradient for a summary statistic.

Here, I try to show a relationship between sale price of a house and a property's size + location.

This looks right. But it isn't. Some medians were estimated with ridiculously small samples. 😱 💔

3/8

Bubble charts make sample sizes obvious.

So, let use bubbles. They have the power to reveal that some medians were based on really small samples.

Crisis averted! 😤 But we can make this even more explicit 👌

4/8

Since we use circles instead of rectangles, we have a bit of room to spare.

We can use that room to double-code the information with text labels. This will make the sample sizes REALLY obvious.

We could even add labels for the medians (if it's not too much clutter for you)

5/8

Want to know how to create these visuals with ggplot?

My new blog post tells you how. But I will give you the main actors right here in this thread.

albert-rapp.de/posts/ggplot2-…

6/8

Bubbles ▶️ geom_point()
Correct bubble size ▶️ scale_size_area()
Pretty labels ▶️ custom string manipulation
Customization of colorbar ▶️ guides()

Heat maps ▶️ geom_tile()
Labels right next to tiles ▶️ coord_cartesian(expand = F)

7/8

Did you enjoy this thread? I hope you did. For more content like this follow @rappa753

Also, please do me a favor and like or retweet the first tweet below. This would help me generate a little bit more engagement for my content 😊

8/8

Want to see even more content like this? Check out my biweekly newsletter.

Every other week I talk about
📈 dataviz,
🌐 Shiny
🧮 statistics.

And it's completely free! alberts-newsletter.beehiiv.com/subscribe

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling