enter image description here

I've tried to plot a map of magnitude earthquakes in Colombia with ggplot. After many efforts, I got it. But, I need to focus in specially area where the data of magnitudes is (4, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5). When I use the same script for this data, I get this:

"Error: Discrete value supplied to continuous scale".

I've used many solutions in blogs but it does not work.

This is my first map and the script

santos <- readOGR("Departamentos_WGS84.shp","Departamentos_WGS84")
map <- fortify(santos)
myData = data.frame(datos)

gg <- ggplot()
gg <- gg + geom_map(data=map, map=map,
                    aes(x=long, y=lat, map_id=id, group=group),
                    fill="#fffcfc", color="#0e0e0e", size=0.15) + 
                    aes(x=long, y=lat, size=Magnitud), color = "red",shape = 21) +
                    scale_size(range = c(0, 8)) + 
                    coord_map() + 
                    theme_bw() + 
                    labs(x=NULL, y=NULL) + 
                    theme(panel.grid=element_blank()) + 
  • I do not understand your question. My data are coordinates (longitude and latitutde) associated with a magnitude. I hope this answers your question. Commented Jan 14, 2016 at 16:23
  • what is the output of this command class(myData$Magnitud)? factor or numeric (this could be the source of your error)
    – rcs
    Commented Jan 14, 2016 at 19:30
  • I guess myData$long and/or myData$lat are character values ("discrete"), because the read.table does not work as expected. And that does not match with map$long, which is numeric. Maybe you can add the output of str(map) and str(myData).
    – lukeA
    Commented Jan 14, 2016 at 19:32
  • Excuse me! With class(myData$Magnitud), I got "factor". Commented Jan 14, 2016 at 20:12
  • 1
    this should be numeric
    – rcs
    Commented Jan 14, 2016 at 20:38

1 Answer 1


I solved this problem with these instructions:

myData$longitude = as.numeric(as.character(myData$longitude))

myData$Magnitude = as.numeric(as.character(myData$Magnitude))

myData$latitude = as.numeric(as.character(myData$latitude))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.