Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8842483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:58:11+00:00 2026-06-14T10:58:11+00:00

I am trying to plot some information that shows full population and then a

  • 0

I am trying to plot some information that shows full population and then a subset of that population by location on a map. I’ve seen data visualizations that use concentric circles or 3-d inverted cones to convey this. I just can’t figure out how to do it in ggplot / ggmap

Here’s a free hand version in Paint that shows a rough idea of what I’m looking to do:
enter image description here

Here’s a rough piece of data for an example:

> dput(df1)
structure(list(zip = c("00210", "00653", "00952", "02571", "04211", 
"05286", "06478", "07839", "10090", "11559"), city = c("Portsmouth", 
"Guanica", "Sabana Seca", "Wareham", "Auburn", "Craftsbury", 
"Oxford", "Greendell", "New York", "Lawrence"), state = c("NH", 
"PR", "PR", "MA", "ME", "VT", "CT", "NJ", "NY", "NY"), latitude = c(43.005895, 
17.992112, 18.429218, 41.751554, 44.197009, 44.627698, 41.428163, 
41.12831, 40.780751, 40.61579), longitude = c(-71.013202, -66.90097, 
-66.18014, -70.71059, -70.239485, -72.434398, -73.12729, -74.678956, 
-73.977182, -73.73126), timezone = c(-5L, -4L, -4L, -5L, -5L, 
-5L, -5L, -5L, -5L, -5L), dst = c(TRUE, FALSE, FALSE, TRUE, TRUE, 
TRUE, TRUE, TRUE, TRUE, TRUE), totalPop = c(43177, 37224, 37168, 
15492, 1614, 88802, 2587, 80043, 78580, 87461), subPop = c(42705, 
36926, 27556, 10827, 774, 39060, 1542, 21304, 53438, 2896)), .Names = c("zip", 
"city", "state", "latitude", "longitude", "timezone", "dst", 
"totalPop", "subPop"), row.names = c(1L, 50L, 200L, 900L, 1500L, 
2000L, 2500L, 3000L, 3500L, 4000L), class = "data.frame")

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:58:12+00:00Added an answer on June 14, 2026 at 10:58 am

    The basic idea is to use separate geoms for the two populations, making sure the smaller one is plotted after the larger one, so its layer is on top:

    library(ggplot2) # using version 0.9.2.1
    library(maps)
    
    # load us map data
    all_states <- map_data("state")
    
    # start a ggplot. it won't plot til we type p
    p <- ggplot()  
    
    # add U.S. states outlines to ggplot
    p <- p + geom_polygon(data=all_states, aes(x=long, y=lat, group = group),
         colour="grey", fill="white" )
    
    # add total Population
    p <- p + geom_point(data=df1, aes(x=longitude, y=latitude, size = totalPop), 
         colour="#b5e521")
    
    # add sub Population as separate layer with smaller points at same long,lat
    p <- p + geom_point(data=df1, aes(x=longitude, y=latitude, size = subPop), 
         colour="#00a3e8")
    
    # change name of legend to generic word "Population"
    p <- p + guides(size=guide_legend(title="Population"))
    
    # display plot
    p 
    

    enter image description here

    From the map, it is clear your data include non-contiguous-US locations, in which case you may want different underlying map data. get_map() from ggmap package provides a couple options:

    require(ggmap)
    require(mapproj)
    map <- get_map(location = 'united states', zoom = 3, maptype = "terrain", 
           source = "google")
    p <- ggmap(map)
    

    After which you add the total and sub Population geom_point() layers and display it as before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to display some information about the data below the plot created
I am trying to plot some data in Flot that should display x-axis in
I am trying to plot some data using pylab scatter function. I'm using pylab.scatter(X,
I am trying to plot some test data (show at the end of this
I am trying to plot some one-dimensional data onto a 2-D plot in MATLAB.
I'm trying to plot some data into a histogram using pyplot.hist as such: hst
I am trying to plot some data and I am getting this error from
I've run into a bit of a hiccup trying to plot some data in
I am trying to create plot some push pins on map using GeoCoordinate as
I'm using GD to plot some simple charts from array point data.. Trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.