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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:22:34+00:00 2026-06-11T00:22:34+00:00

I´m trying to produce a worldmap using ggplot2 in R. It schould be a

  • 0

I´m trying to produce a worldmap using ggplot2 in R. It schould be a countrybased heatmap. The data I’m working on comes from twitter and I want to show where the tweets come from. There are 2 problems:

  1. the integrated data

    map_data("world")
    

    gives me a map older the 20 years (USSR).

    map_data("world2")
    

    seems damaged. or there is some ordering issue but I don’t know how to solve it.

http://schloegl.net/supersambo/world2.pdf

  1. I would like to change the colour breaks and don’t know how to access it. Since Brazil is the only country easy to read it would be important to edit the breaks and show the difference between countries with less then 1000 tweets.

http://schloegl.net/supersambo/world.pdf

here is my code

    WD <- getwd()
    if (!is.null(WD)) setwd(WD)

    library(maps)
    library(plyr)
    library(ggplot2)

    twitter=read.csv("/Users/stephanschloegl/Studium/Diplomarbeit/rawData/c_userInfo/c_userInfo.csv",header=TRUE,check.names=FALSE,sep=";")

    #read geodata
    cities=read.csv("GeoWorldMap/cities.txt",header=TRUE,check.names=FALSE,sep=",")
    countries=read.csv("GeoWorldMap/countries.txt",header=TRUE,check.names=FALSE,sep=",")

    #find countries for twitter$timezone
    lista <- twitter$time_zone
    country_ids <- cities$CountryID[match(lista,cities$City)]
    country <- countries$Country[match(country_ids,countries$CountryId)]

    #FREQENCIES
    frequencies <- as.data.frame(table(country))
    names(frequencies) <- c("region","freq")
    #change 0's to NA
    frequencies$freq[frequencies$freq==0] <- NA

    #load world data
    world <- map_data("world2")
    #Delete Antarctica
    world <- subset(world,region!="Antarctica")


    #merge twitterdata and geodata
    world$tweets <- frequencies$freq[match(world$region,frequencies$region,nomatch=NA)]

    map <- qplot(long, lat, data = world, group = group,fill=tweets,geom ="polygon",ylab="",xlab="")
    #this does'nt work
    map + scale_colour_hue(name="Number of\nTweets",breaks=levels(c(10,20,100,200,1000)))
    map
  • 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-11T00:22:36+00:00Added an answer on June 11, 2026 at 12:22 am

    That’s because scale_colour_hue() is for discrete scales. You have to use scale_fill_gradient() because you want to change the fill not the outline.

        map + scale_fill_gradient(name="Number of\nTweets", trans = "log",
                               breaks = c(10, 20, 100, 200, 1000))
    

    There you go. You have also put levels in the breaks which makes no sense, the number of tweets is numeric.

    enter image description here

    You can get the new map here and follow the instructions in that post to make it work.

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

Sidebar

Related Questions

I'm trying to produce a plot with two lines using data taken from stdin.
I am trying to produce a heat map using ggplot2. I found this example
Using CakePHP 1.2, I am trying produce a GROUP BY query: SELECT `categories`.*, COUNT(`entities`.id)
I'm trying to produce a clipping area in a UIView that's generated from path
I am trying to produce a proof of concept shipping logging from Log4J through
I'm trying to produce a dropdownlist for GetAllRoles using the role provider. I can
I'm trying to produce some graphs using GNUplot with a makefile. I would like
I'm trying to produce a string using a NSDate category in this way: NSString*
I am trying to produce a nested XML document from a flat XML document
I'm trying to produce gcd a files from an iOS Xcode 4.2 (4D199) project

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.