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)
datos=read.table("coord.txt",header=T,dec=",",sep=";")
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) +
geom_point(data=myData,
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()) +
theme(panel.border=element_rect())
gg
class(myData$Magnitud)
?factor
ornumeric
(this could be the source of your error)myData$long
and/ormyData$lat
are character values ("discrete"), because theread.table
does not work as expected. And that does not match withmap$long
, which is numeric. Maybe you can add the output ofstr(map)
andstr(myData)
.numeric