Skip to content
R for the Rest of Us Logo

Compare Locations/Events with Geobubble Charts (02_04)

This lesson is locked

Get access to all lessons in this 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

Use the your-turn.R script in 02_04 to create a geobubble chart of the most popular airports in the US.

Keep in mind the following two requirements:

  • Ensure small circles are not overlapped by bigger circles

  • Give the circles both a fill color and border color

Learn More

The geobubble chart I showed in the slides is slightly more refined than the one we built together. You can take a look at the slide code on GitHub to see how it was built.

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

Jordan Trachtenberg

Jordan Trachtenberg

May 10, 2022

Hi Charley, do you know of any good resources for using the API for the US Bureau of Labor Statistics? I was able to get an API key but am interested in salary data for certain jobs by county. Thank you!

Jordan Trachtenberg

Jordan Trachtenberg

May 10, 2022

Oops, sorry I misspelled your name. Couldn't figure out a way to edit my first response.

Charlie Hadley

Charlie Hadley

May 10, 2022

Hi Jordan!

No worries about the typo! It looks like the {blsR} package doesn't even require you to register for an API! There isn't much documentation for it and you'll need to install the package from GitHub by following the instructions on the repo.

Cheers,

Charlie

Jordan Trachtenberg

Jordan Trachtenberg

May 10, 2022

Thank you so much, Charlie. I will look at this package.

Yuriy Zharikov

Yuriy Zharikov

July 20, 2022

Hi Charlie, Could you point to how I can change the number of categories/breaks in the legend? I have tried doing something like this:

geom_sf(data = subset(plot_data_sf, species_code == "MAMU"), aes(size = dens_10km_o), alpha = 0.5, pch = 21, color = parknmca, fill = parknmca)+ scale_size_continuous(breaks=c(0, 100, 200, 400, 600),labels=c("0", "100", "200", "400", "600")) But this has not changed the default number of breaks. Thank you, Yuri

Charlie Hadley

Charlie Hadley

July 21, 2022

Hello Yuri,

Is it possible for you to share the dataset with me? It's not possible for me to understand what's not working without seeing the data.

It might be easier to work with the example dataset I provided as we both have access to that. Could you either share you data or modify this example?

ggplot() +
  geom_sf(data = us_contiguous_sf) +
  geom_sf(data = us_airport_passengers_2019,
          aes(size = total_passengers),
          pch = 21,
          alpha = 0.7,
          fill = "grey70") +
  geom_label_repel(data = airport_passenger_extremes,
                   aes(x = long,
                       y = lat,
                       label = airport),
                   nudge_y = c(-2, 2)) +
  scale_size_area(max_size = 10,
                  breaks = c(1E7, 3E7, 4E7),
                  labels = c("10 Mil", "30 Million", "40 Very big stacks")) +
  theme_void() +
  theme(legend.position = "bottom")

Thanks,

Charlie

Yuriy Zharikov

Yuriy Zharikov

July 21, 2022

Hi Charlie, Your example is what I needed. The breaks had to be defined under the scale_size_area() call. All good. Thank you very much. Enjoyed your course. Yuri