Error: Must request at least one colour from a hue palette.

hi,

I am trying to create a map with cities label in it, but it keeps giving the following error:

library(mapdata)
library(ggplot2)

pk <- ggplot2::map_data('world2', 'pakistan')
class(pk)
head(pk)
ggplot(pk, aes(x = long, y = lat, group = group)) +
geom_polygon()
dev.off()
library(ggfortify)
pk <- map('world2', 'pakistan', plot = FALSE, fill = TRUE)
class(pk)
autoplot(pk)
p <- autoplot(pk, geom = 'polygon', fill = 'subregion') +
theme(legend.position = "none")
p
cities <- get('world.cities')
cities <- cities[cities$country.etc == 'Pakistan',]
head(cities)
p + geom_point(data = cities, aes(x = long, y = lat),
colour = 'blue', size = 0.1)
Error: Must request at least one colour from a hue palette.
p + geom_point(data = cities, colour = 'blue', size = 0.1)
Error: Must request at least one colour from a hue palette.

Could anyone suggest what's the issue in the code? I copied the code from a website (https://cran.r-project.org/web/packages/ggfortify/vignettes/plot_map.html) as I am still learning mapping strategies in RStudio.

if you look at the pk object at the point the above code is run you will see that unlike japan, pakistan does not have subregion labels, just NA values.
so subregion can't be used to fill by .
I swapped subregion for blue and it worked to give me a blue coloured map

Thanks for the prompt response.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.