Analyze Data: Five Ways You Can Make Interactive Maps

September 8, 2015
By

(This article was first published on Plotly Blog, and kindly contributed to R-bloggers)

Plotly’s new map making tools let you tell stories about data as it relates to geography. This post shows five examples of how you can make and style choropleth, subplot, scatter, bubble, and line maps. We made these maps with our APIs for R and Python. In the future, we will also support maps from our web app. Let us know if you have suggestions or feedback. You can integrate your maps with dashboards, IPython Notebooks, Shiny, PowerPoint, reports, and databases. For users who want to securely share graphs and data within a team and make interactive dashboards, contact us about Plotly on-premise.

Bubble Maps

Bubble charts allow you to show the location of an event as well as a third and fourth variable indicated by size and color. This bubble map shows Ebola cases in Africa. The zoomed in portion shows Guinea, Sierra Leone, and Liberia, where we can see bubbles. The bubbles indicate the the number of cases of Ebola (size) and the month of the case (color). You can toggle the bubbles on and off by pressing the legend. To refer to countries and states, we use country codes published by the International Organization for Standardization.

Choropleth Maps

Choropleth maps use shades or patterns in proportion to the measurement of the statistical property you’re examining. Different color scales let you communicate your message based on the type of data you have. In this case, we’re examining global GDP. The sequential color scale lets us quickly scan the map to look for the darkest blue–visible in China and the US.

Lines on Maps

Lines on maps let you overlay data showing movement or activity between regions. In this case, we’re showing American Airlines flights between cities. We can state that we would like to use latitude and longitude and, for example, “USA” as our scope, then Plotly draws the relevant point on the map. You can set the layout options shown below from our web app or from our APIs. That means developers can work with designers and non-developers. In this case we’re using the option for “Azimuthal equal area”. Head to our web app to try the other options.

(Hover for airport names)" style="display: block; text-align: center;">(Hover for airport names)" style="max-width: 100%;width: 600px;" width="450" onerror="this.onerror=null;this.src='https://plot.ly/404.png';"/>

Scatter Plots on Maps

Like a bubble chart that uses size, you can use color in a scatter chart to indicate a third variable. In this case, we’re adding a color scale to show the number of incoming flights to each US airport. We can customize the text shown when you hover your mouse: here it shows the latitude, longitude, airport name, location, and number of incoming flights. We can also control the geographic styles of our map by turning on and off the land, lakes, rivers, countries, and subunits in our plot.

(Hover for airport names)" style="display: block; text-align: center;">(Hover for airport names)" style="max-width: 100%;width: 600px;" width="450" onerror="this.onerror=null;this.src='https://plot.ly/404.png';"/>

Map Subplots and Small Multiples

Now for the grand finale. The chart below shows the number of new Walmart stores opened yearly from 1962 to 2006. We made this map with Python. If you toggle your mouse over a given year, it will zoom in.

To leave a comment for the author, please follow the link and comment on their blog: Plotly Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)