plotly 4.7.0 now on CRAN

[This article was first published on R – Modern Data, 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.

I’m super excited about plotly 4.7.0 – it includes numerous improvements and new features related to performance, mapping, and API requests. It also includes support for something folks have wanted for a very long time – fixed coordinates via ggplotly()! In other words, if you use coord_equal(), coord_fixed(), etc to specify a ratio between the visual represntation of data units on positional axes (a key property of maps) in ggplot2, it should just workTM when converted via ggplotly()! It also has support for the stellar new geom_sf() – an official ggplot2 geom that is so new, it is currently only available through the development version of ggplot2. For this and other reasons, I recommend using the development version of ggplot2 if you can:


At plotcon Oakland, I held a workshop where I touched on why the new sf package and geom_sf() are so awesome for mapping in R, and how to make these maps interactive via ggplotly(). There are lots of other goodies in those workshop slides, such as embedding raster images, converting ggmap plots, an overview of animation, highlighting, and filtering. Also, some of the “your turn” exercises show you how to combine these concepts to do neat stuff like outline geo-spatial polygons on hover or annotate geo-spatial polygons on click:

Updating to 4.7.0 may also yield big speed improvements at print time, especially when plotting a large number of lines, paths, or polygons in a single trace. For a bit of context, this fairly simple example with 46 lines now takes a third of the time to print (about 1 instead of 3 seconds).

plot_ly(txhousing) %>%
  group_by(city) %>%
  add_lines(x = ~date, y = ~median)

The speed-up is a direct result of making (the previously internal, but now exported) function group2NA() much more efficient (huge thanks to Matt Summersgill for the help here). This function is used on any ggplot2 geom which can be reduced to a path or a polygon, so the impact should be large and widespread! This improvement was made possible through the new data.table dependency, which I hope to leverage more down the road to make other plots faster to print.

This release also updates the plotly.js version from 1.26.1 to 1.27.1, so you can leverage the latest plotly.js features, such as parallel coordinates and Sankey diagrams. Numerous other improvements and bug fixes (especially for api_create()) are coming with this release, please see the NEWS file for more info.

Happy plotting!

To leave a comment for the author, please follow the link and comment on their blog: R – Modern Data. 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.

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)