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 8967731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:18:39+00:00 2026-06-15T17:18:39+00:00

I am plotting a map with different study sites of malaria parasite drug resistance.

  • 0

I am plotting a map with different study sites of malaria parasite drug resistance. The points of the study sites are sized relative to how many malaria parasites were sampled and the fill of the points is a gradient from 0 to 1 of the proportion of malaria parasites that were drug resistant. The following code reveals the map below:

###GENERATING AFRICA MAP###
africa = readOGR("/Users/transfer/Documents/Mapping Files/Africa Countries/Africa_SHP",    layer="dissolved")
#FIXING THE NON-NODED INTERSECTS#
africa = gBuffer(africa, width=0, byid=TRUE)
#CREATING DATA FRAME FOR GGPLOT#
africa.map = fortify(africa, region="ID")

###PLOTTING SPM.437###
#SCALING THE SAMPLE SIZE USING CUBE-ROOT#
size = d.spm.437$Tot437^(1/3)
#PLOTTING#
ggplot(africa.map, aes(x = long, y = lat, group = group)) + 
    geom_polygon(colour="black",   size=0.25, fill="white", aes(group=group)) +
    geom_point(data = d.spm.437, aes(x = long, y = lat, fill=Frc437, group=NULL, size=Tot437), 
        size=size, shape=21, colour="black", size=0.5)

enter image description here

I tried using a color option but it did not work:

ggplot(africa.map, aes(x = long, y = lat, group = group)) + 
    geom_polygon(colour="black",   size=0.25, fill="white", aes(group=group)) +
    geom_point(data = d.spm.437, aes(x = long, y = lat, colour="red", fill=Frc437, group=NULL, size=Tot437), 
        size=size, shape=21, colour="black", size=0.5)

Anybody know how to get the color of the fill to show a scale of red, lighter being 0 and darker being 1?

  • 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-15T17:18:41+00:00Added an answer on June 15, 2026 at 5:18 pm

    As I mentioned in my comment, I think you’re a little confused about setting vs mapping aesthetics.

    You map aesthetics to a variable in your data frame inside of aes(). So, aes(color = var) maps the color aesthetic to the variable var, and you get a legend to show how color varies with var. If you set color, outside of aes(), to a single value, then you are simply setting all points to be a single color: color = "red".

    The reason I suspect you’re confused is that you have size=Tot437 inside of aes(), and then both size=size and size=0.5 outside of aes().

    Finally, to change the color palette, you need to be aware of the scale_color_* functions (as well as scale_fill_*, scale_size_* etc). Here’s a simple example to get you started:

    dat <- data.frame(x = rnorm(50),
                      y = rnorm(50),
                      f = runif(50))
    
    library(ggplot2)
    library(munsell)
    cl <- mnsl(c("5R 2/4", "5R 7/10"))
    
    ggplot(dat,aes(x,y,fill = f)) + 
        geom_point(size = 5,shape = 21) + 
        scale_fill_gradient(low = cl[1],high = cl[2])
    

    How did I come up with that crazy looking color specification? Just from the first few lines of scale_fill_continuous and then poking around in the munsell package a bit.

    Edit: I completely missed that you were actually using pch = 21 which is basically the only point shape for while the fill aesthetic makes sense, so I’ve edited to remove my comments on that score.

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

Sidebar

Related Questions

Map size with lat/long 38.31536111,-76.55011111 is different from map with lat/long 59.5624775,-139.7410994 (plotting points
I'm trying to plot points from study sites with a background map of Africa.
I am dynamically plotting several points onto a google map. I'm trying to find
I have an application which requires plotting two locations on google map ? One
I have many coordinates that I am plotting using a MKMapOverlay and CoreLocation and
I am plotting data on a map using this code: import numpy as np
I am plotting a contour over the mercator(planar) world map in MATLAB. And I
I made a cool map once by plotting kml coordinates in R, and overlaying
I'm working on a simple Android app for plotting routes on a map. All
I am plotting data from an aircraft on a map and I would like

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.