Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Discrete value supplied to continuous scale #31

Open
IssamHu opened this issue Mar 10, 2021 · 2 comments
Open

Error: Discrete value supplied to continuous scale #31

IssamHu opened this issue Mar 10, 2021 · 2 comments

Comments

@IssamHu
Copy link

IssamHu commented Mar 10, 2021

Dear Sir,
I used the following cods:
`library("ggplot2")

library("ggmap")

library("scatterpie")

ap <- c(left = 36, bottom = 15, right = 60.4, top = 32)

myMap <- get_map(location=ap, source="stamen",
maptype="terrain", zoom = 9 ,crop=FALSE)

ggmap(myMap) +
scale_fill_etopo() +
coord_cartesian(expand = 0) +
labs(y = "Latitude", x = "Longitude") +
theme(legend.position = "none") +
geom_scatterpie(aes(x=Longitude, y=Latitude, group=Country), data=Piedata,
cols=c("Legal", "Illegal"), pie_scale = 1,
sorted_by_radius = FALSE, legend_name = "type",
long_format=FALSE)`

for the data:

Piedata
Country Legal Illegal Latitude Longitude
1 A 0.375 0.625 29.74247 48.41323
2 B 0.852 0.148 27.77500 49.14698
3 C 0.345 0.655 26.31520 50.49300
4 D 0.562 0.439 25.56074 51.64831
5 E 0.410 0.590 25.45679 54.72089
6 F 0.750 0.250 21.11154 59.32937

but I get this error:
Error: Discrete value supplied to continuous scale

Please can you help me to solve this issue.

Thanks,
IssamHu

@besibo
Copy link

besibo commented Mar 11, 2021

@IssamHu Please, see my answer here
It's usually not a great idea to post he same question in several places, especially when the error message you're facing has nothing to do with the package maintainer(s) you're asking your question to. You sent your question to the maintainers of ggmap, scatterpie and marmap, when you should have just googled your error message to get basically the same answer I gave you on the marmap repo issue page...

@r2evans
Copy link

r2evans commented Jan 3, 2024

For the record, it is in fact possible to use fill= in other layers when adding scatterpie layers, by using ggnewscale (or some other package that allows multiple scales for fill=/color=). See option 2 in https://stackoverflow.com/a/77754342/3358272.

Bottom line, perhaps (untested) the original code above could work with

ggmap(myMap) +
  scale_fill_etopo() +
  coord_cartesian(expand = 0) +
  labs(y = "Latitude", x = "Longitude") +
  theme(legend.position = "none") +
  ggnewscale::new_scale_fill() +                                  # <---- ADD
  geom_scatterpie(aes(x=Longitude, y=Latitude, group=Country), data=Piedata,
                  cols=c("Legal", "Illegal"), pie_scale = 1,
                  sorted_by_radius = FALSE, legend_name = "type",
                  long_format=FALSE)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants