Python&R: Replace bar charts with dot plots ver. 1

Last Updated on February 23, 2022 by shibatau

I. What shall we learn?

We will learn an alternative to bar charts when your data is complex: the Cleveland dot plot. See: Replace your complex bar chart with a dot plot to make it better understood

II. Cleveland dot plots

Let’s take an example. The data is the results of English and Japanese.

I have created a bar plot and a dot plot with R. Here is the codes:

# import libraries
# load the data
data <- read_csv("")
# get means of english scores by nationality
data |>
  group_by(nationality) |>
  summarize(average = mean(english)) |> 
  arrange(average) -> data_nationality
# create a bar plot
ggplot(data_nationality) +
  geom_bar(aes(reorder(nationality, average), average), stat = 'identity') +
# create a dot plot
ggplot(data_nationality) +
  geom_point(aes(reorder(nationality, average), average), stat = 'identity') +
Bar plot

Dot plot

Which do you like better? Maybe I prefer the former to the latter in this case but I don’t think any serious difference between them. It seems mainly a matter of personal preference to choose one better than the other.

To be continued.

About shibatau

I was born and grown up in Kyoto. I studied western philosophy at the University and specialized in analytic philosophy, especially Ludwig Wittgenstein at the postgraduate school. I'm interested in new technology, especially machine learning and have been learning R language for two years and began to learn Python last summer. Listening toParamore, Sia, Amazarashi and MIyuki Nakajima. Favorite movies I've recently seen: "FREEHELD". Favorite actors and actresses: Anthony Hopkins, Denzel Washington, Ellen Page, Meryl Streep, Mia Wasikowska and Robert DeNiro. Favorite books: Fyodor Mikhailovich Dostoyevsky, "The Karamazov Brothers", Shinran, "Lamentations of Divergences". Favorite phrase: Salvation by Faith. Twitter: @shibatau

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.