Forum Discussion
Zooming in on RStudio (heat)maps
Anonymous,
I see. I can copy paste the syntax, which I already tried to use.
library("ggmap", lib.loc="~/R/win-library/3.2")
library("ggplot2", lib.loc="~/R/win-library/3.2")
Country.map = get_map(location = "Location", zoom = 8, color="bw") ## get MAP data
options(stringsAsFactors=T) ## need to run this --- weird ggplot bug=!
p <- ggmap(Country.map)
p <- p + stat_density_2d(bins=150, geom='polygon', size=2, data=dataset, aes(x = Longitude, y = Latitude, alpha=..level.., fill = ..level..))
p <- p + scale_fill_gradient(low = "yellow", high = "red", guide=FALSE) + scale_alpha(range = c(0.02, 0.8), guide = FALSE) +xlab("") + ylab("")
p + theme(axis.title=element_blank(),
axis.text=element_blank(),
axis.ticks=element_blank()) + ggtitle("Virksomheder")
This is only my starting point. It might very we be, that this syntax is entirely wrong for what I am trying to do. The data varies. Its just a lot of company data. So there are name, address, city, Mother company, long., lat., Ownership, in which business it operates in, and so on.
If you need anymore information please ask me :) Please keep in mind that the result below is "ok". But I do not seek a static solution. When I filter on one particular region, I would like it to only show that, and most importantly, To zoom in that particular region.
Screenshot of current result:
Hey DatamindsMBM,
Check out this really interesting article here.
The author uses the library "ggmap" to set the location range and zoom using this:
library(ggmap) test <- get_map(location = 'chicago', zoom = 11) ggmap(test)
Also, the article shows how to make a grid inside the map, so it doesn't looks so meshed together.
You mentioned how you would like to zoom into a specific region when filtered, so maybe look to make the location dynamic and based off the city name.
Hope this helps,
Alan