Barplots on a Map
Solution 1:
You should also use the mapproj
package. With the following code:
ggmap(india) +
geom_subplot(data = df1, aes(x = long, y = lat, group = University,
subplot = geom_bar(aes(x = Category, y = Count,
fill = Category, stat = "identity"))))
I got the following result:
As noted in the comments of the question: this solution works in R 2.15.3 but for some reason not in R 3.0.2
UPDATE 16 januari 2014: when you update the ggsubplot package to the latest version, this solution now also works in R 3.0.2
UPDATE 2 oktober 2014: Below the answer of the package author (Garret Grolemund) about the issue mentioned by @jazzuro (text formatting mine):
Unfortunately,
ggsubplot
is not very stable.ggplot2
was not designed to be extensible or recursive, so the api betweenggsubplot
andggplot2
is very jury rigged. I think entropy will assert itself as R continues to update.The future plan for development is to implement ggsubplot as a built in part of Hadley's new package
ggvis
. This will be much more maintainable than theggsubplot
+ggplot2
pairing.I won't be available to debug ggsubplot for several months, but I would be happy to accept pull requests on github.
UPDATE 23 december 2016: The ggsubplot
-package is no longer actively maintained and is archived on CRAN:
Package ‘ggsubplot’ was removed from the CRAN repository.
Formerly available versions can be obtained from the archive.
Archived on 2016-01-11 as requested by the maintainer .