plotly 4.7.0 now on CRAN

May 30, 2017
By

(This article was first published on R – Modern Data, and kindly contributed to R-bloggers)

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:

devtools::install_github("tidyverse/ggplot2")
install.packages("plotly")

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.

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.

Search R-bloggers

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)