Forum Discussion
Zooming in on RStudio (heat)maps
Martin,
I've found you need to be very prescriptive with some of the R functions - e.g. defining specific xlim and ylim. Can you provide some more details on your issue - the R functions and libraries you are trying to use, sample data etc., screenshots of the result you are getting?
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:
- alanhodgson9 years agoSolution Supplier
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
- Anonymous9 years agoNot applicable
That's cool.
I didn't think the ggmap package was supported in PowerBI - see 'Supported Packages' at https://powerbi.microsoft.com/en-us/documentation/powerbi-service-r-visuals/
If you have Lat and Lon in your dataset, have you played around with bounding boxes (might still be classed as 'Experimental' with Google maps), calculating a zoom level to pass to oyur map request?
Alternately, can you limit the scale of your X and Y axis ?
- DatamindsMBM9 years agoFrequent Visitor
Oddly enough, if you go to https://powerbi.microsoft.com/en-us/documentation/powerbi-service-r-visuals/, and you search for ggmap, it doesn't show.
Anyhow, I haven't played around with bounding boxes. And I don't think that I can limit my X/Y axis, but I'm actually not sure.