Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Jeremy Yoder wrote a wrote a post on The Molecular Ecologist about plotting location data in ggplot. It is a very informative post. However, I disagree with one (minor) aesthetic choice. The species in his figure have different colors and shapes. I am very opinionated about data visualization, all my friends can attest. My opinion follows Stephen Few’s “Practical Rules for Using Color in Charts” “Use different colors only when they correspond to differences of meaning in the data.”< !--more-->
We can apply Few’s rule to this plot, “Use different colors [and shapes] only when they correspond to differences of meaning in the data.” Conforming to this rule, below is my attempt.
Here is the code To create my figure. For more information about the data, and more in depth instruction on using ggplot and the functions to convert the distribution locations to polygons refer to Jeremy’s post.
Leaflet
My go to packages for plotting location data is leaflet. I use leaflet because adding a basemap is easy and the interactivity makes it easy for exploring the exact locations of data. There are several instances that the popup markers have helped me QA/QC my data. Below is the code to reproduce the plot with leaflet. I find using geojsons to be the easiest way to add polygons to leaflet maps.
It is entirely possible that the changing the shape and color in the original post is to show that it can be done. I undertook this as an exercise to practice my R mapping skills and present an alternative solution to mapping in R using leaflet.
Please check out The Molecular Ecologist website. It is a wonderful resource for R tutorials and discussion of all aspects of ecology and evolution. You can read more of Jeremy’s helpful tutorials and articles at The Molecular Ecologist.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.