Site icon R-bloggers

RObservations #43 : Control Individual Label Positions In mapBliss With `_flex()` Functions

[This article was first published on r – bensstats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Introduction

After introducing the mapBliss package to the world, I was pleased to see that people started using it and were experimenting with making their own map art! On Github, the package got a few stars, some issues opened/closed and some improvements have been made since my last blog on the topic.

If you haven’t followed the journey of mapBliss so far check out these blogs:

  1. I reverse-engineered Atlas.co (well, some of it)

  2. Using the MapBox API with Leaflet

  3. Plotting Flight Paths on Leaflet Maps

  4. Packaging My Route Map Code! Introducing mapBliss.

While I thought the job was done for the package, sharing it with the world showed me what improvements and features can be added to it. In this blog I share a new line of functions available in mapBliss which allow for flexible label placement and future development features which I refer to as _flex() functions.

Using _flex() functions

The _flex() functions are the product of a Github issue which was posted noting that the original mapBliss functions only offer single direction label placement and universal label padding. It would be more useful to be able to control placement of each label. This feature enables users to have to have more options for label placement where a single direction for all labels would not be as aesthetically pleasing without deviating much from the original function syntax.

A great example of how the _flex() functions work is:

# devtools::install_github('benyamindsmith/mapBliss')

library(mapBliss)

plot_hybrid_route_flex(addresses=c("Amsterdam","Freddrikshavn","Kristiansand","Oslo"),
how=c("car","flight","car"),
weight=3,
colour="red",
label_position = c("left", "right","left","top"),
text_indent= c("1em","1em","1em","0.5em"),
mapBoxTemplate="https://stamen-tiles.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg"
)

Thank you GTBoon72 for sharing this with me!

Conclusion

_flex() functions have now been added to the mapBliss! Be sure to install get the newest updates by running devtools::install_github("benyamindsmith/mapBliss) in your R console! If you find a bug or want a feature in this package feel free to open an issue. Let me know what you make!

Thank you for reading!

Want to see more of my content?

Be sure to subscribe and never miss an update!

To leave a comment for the author, please follow the link and comment on their blog: r – bensstats.

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.