Plotly: ggplot2 extension packages

Created on 28 Apr 2016  路  15Comments  路  Source: ropensci/plotly

Master list of ggplot2 extension packages with custom geoms/packages that we'd like to support:,

  • [ ] ggraph
  • [ ] ggforce
  • [ ] ggrepel
  • [ ] ggtern
  • [ ] [tidybayes](https://github.com/ropensci/plotly/issues/1667)
  • [ ] [ggtree](https://github.com/GuangchuangYu/ggtree)
  • [ ] [ggpolypath](https://github.com/ropensci/plotly/issues/1339)
  • [ ] geomnet
  • [ ] [ggjoy](https://github.com/clauswilke/ggjoy)
  • [ ] [ggflags](https://github.com/baptiste/ggflags)
  • [ ] forecast (GeomForecast) #1568
  • [ ] [survminer](https://github.com/kassambara/survminer)
  • [ ] [plotROC](https://github.com/sachsmc/plotROC/)
  • [ ] [tidyquant](https://github.com/business-science/tidyquant)
  • [ ] ggtheme's geom_rangeframe
  • [ ] [treemapify](https://github.com/wilkox/treemapify) (although, this seems to have significant overlap with ggraph)
  • [ ] directlabels #1244
  • [ ] ggsurv (GeomConfint) #1404
  • [ ] ggimage #1442
  • [ ] [statebins](https://github.com/ropensci/plotly/issues/1558)
  • [ ] ggalluvial (https://github.com/ropensci/plotly/issues/1614)
  • [ ] ggpubr::stat_compare_means() (and maybe others from ggpubr?)
  • [ ] [corrr](https://github.com/ropensci/plotly/issues/1684)
  • [ ] [ggpmisc](https://github.com/ropensci/plotly/issues/1687)
  • [ ] [ggnewscale](https://github.com/ropensci/plotly/issues/1661)
  • [ ] [Ipaper](https://github.com/ropensci/plotly/issues/1672)
  • [ ] [qqplotr](https://github.com/ropensci/plotly/issues/1705)

If any community members are interested in implementing a hook into ggplotly() for a custom geom, see https://cpsievert.github.io/plotly_book/translating-custom-ggplot2-geoms.html

If anyone would like to sponsor work on a specific geom/package, please get in touch.

ggplotly good-for-first-time-contribution help wanted

Most helpful comment

can I just add a huge +1 for ggrepel support via plotly::ggplotly()?

The ggrepel repel-optimisation of course, wouldn't be available in pure JS.
Any chance it could be replicated in plotly?

Would be nice to have the repelled-labels resized/react to the size of the plots.

All 15 comments

I am working in the forecast package right now and would really like to use Plotly for my dashboard! I have found the following links really helpful for converting forecast to ggplot2 :
http://robjhyndman.com/hyndsight/forecasts-and-ggplot/

http://davenportspatialanalytics.squarespace.com/blog/2012/3/14/plotting-forecast-objects-in-ggplot-part-1-extracting-the-da.html

http://davenportspatialanalytics.squarespace.com/blog/2012/3/21/plotting-forecast-objects-in-ggplot-part-2-visualize-observa.html

Although I will admit I think there is a bug with the geom_ribbon function in plotly. I can plot the ggplot perfectly with my prediction band, but the ggplotly interpretation of the ggplot2 is converting my NA's for the observed values into values for the geom_ribbon

ggplot2 image
image

ggplotly
image

can I just add a huge +1 for ggrepel support via plotly::ggplotly()?

The ggrepel repel-optimisation of course, wouldn't be available in pure JS.
Any chance it could be replicated in plotly?

Would be nice to have the repelled-labels resized/react to the size of the plots.

I'm working on a hook for my fork of ggflags (which substitutes SVGs for the PNGs originally used). I'm trying to get my head around is_basic and geom2trace鈥攊n particular, how they fit into the broader plot conversion process and how much I can model one of them on, say, GeomPoint.

EDIT: also documenting as I work things out on Stack Overflow. Any expertise or guidance from people here would be appreciated, though!

I don't think plotly.js has the ability to accept arbitrary SVG/PNG for marker definitions...you might be able to leverage marker color gradients, but I'm not immediately sure.

Anyway, I remember having a look at ggflags and was thinking we could probably convert them in a similar way to annotation_raster(). Have a look at layers2layout() and let me know you have questions!

Mmmm, I think I see how it works. The main problem I see is that geom_flag _isn't_ an annotation. That means you'd have to manually evaluate its aesthetics to position and size it, and I don't think it would work with facets (I'm also guessing that annotations don't get hovertexts鈥攊s that correct?).

Annotations are raster objects -- that's also true for geom_flag, correct? If so, the implementation would be very similar (which works for facets)

In the case of my fork of ggflags, I've switched to using SVGs in order to size them without blowing out file size. But my concern is less about the file format and more about associating the flags with the source dataset in the way that traces do. I don't want to just decorate the layout with flags; I'm interested in using them as actual points (or at least giving the user that impression).

Would be super awesome if geom_text_repel() would work with plotly since I mainly use plotly for plots totally crowded with text :+1:

apparently ggjoy is deprecated in favor of ggridges

will love to see ggraph implemented.

about the comment:
" treemapify (although, this seems to have significant overlap with ggraph) "
it means that i must choose one or the other ?
in case both get implemented and i want to use both ?

thanks in advance, and keep the awsome work :D !

I'd love to see geom_dl or geom_text_repel added to ggplotly function. I would also like to see stat_cor supported. It provides an easy way to display significance and correlation values.

I also wanted to add an issue when setting custom themes. Omitting the theme() function results in normal functioning. The error is :

Error in convertUnit(x, unitTo, "y", "dimension", "y", "dimension", valueOnly = valueOnly) :
'x' argument must be a unit object

Example:
p2 <- ggplot(mtcars, aes(x = hp, y = mpg)) +
geom_point() +
geom_smooth(method = "lm", se = F) +
theme_tufte() +
facet_wrap(~cyl, scales = "free") +
theme(
panel.background = element_rect(fill = NA, color = "gray"),
axis.title = element_text(size = 12, face = "bold"),
axis.text = element_text(size = 10, face = "bold", color = "black"),
axis.line.x.bottom = element_line(color = "gray"),
axis.line.y.left = element_line(color = "gray"),
legend.position = "none",
strip.text = element_blank()
)
p2
ggplotly(p2)

I'd like to second the request for a ggridges implementation.

library(ggridges)
(
  ggplot(diamonds, aes(price, cut)) + 
    stat_binline(bins = 20, scale = .7, draw_baseline = FALSE) +
    theme_ridges()
) %>% ggplotly()
(
ggplot(iris, aes(x = Sepal.Length, y = Species)) +
  geom_density_ridges(rel_min_height = 0.005) +
  scale_y_discrete(expand = c(0.01, 0)) +
  scale_x_continuous(expand = c(0.01, 0)) +
  theme_ridges()
) %>% ggplotly()

@cpsievert Can you say if there is any active development or planning to support for ggraph anytime soon? Saying "we want to support it" is great, but I wonder what sort of priority is it to you?

Treemap has just been added to plotly.js
See https://github.com/plotly/plotly.js/pull/4185

Any chance geom_ma()from the tidyquant package will be implemented with ggplotly()?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ratnanil picture ratnanil  路  3Comments

crarlus picture crarlus  路  3Comments

gtumuluri picture gtumuluri  路  7Comments

robertleitner picture robertleitner  路  5Comments

kranthikandi picture kranthikandi  路  4Comments