Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DatamindsMBM
Frequent Visitor

Zooming in on RStudio (heat)maps

Hello community,

 

I am trying to use R with Power BI. In specifics, I would like my RStudio (heat)map to behave like any other Power BI map. When I choose to filter on a company (given that I'm using company data), or a region, the Power BI map zooms in on that particular spot. The R-visualization just filters and then stays at the same frame as before. in other words: it doesn't zoom in on what I filtered on.

 

I can't seem to find a solution to this anywhere, and I would therefore like to spark a discussion about this with the purpose of finding a solution.

Again, it is important for me to emphasize that I do not want a static view, but a dynamic view, which follows what I filter on.

 

Best regards,

Martin

Junior associate at Dataminds

5 REPLIES 5
Anonymous
Not applicable

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:

2016-12-16 10_00_03-Experian 20161214 - Power BI Desktop.png

 

Anonymous
Not 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 ?

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.

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.