I have 2 issues using function `ggplotly` in R: --- **Question 1** What are the ways to keep `R` _plotmath_ expressions while converting `ggplot2` plots to `plotly` format using function `ggplotly`? Now the expressions are converted to `[object Object]` as in this example below: ``` library(ggplot2) library(plotly) qplot(mpg, wt, data = mtcars) + ggtitle(expression(bar(x) == sum(frac(x[i], n), i==1, n))) ``` [](http://i.stack.imgur.com/0lA4g.jpg) ``` ggplotly() ``` [](http://i.stack.imgur.com/rLoxZ.jpg) --- **Question 2** How to get rid of **double** labels in the legend of `plotly` graph and make them look like in `ggplot2 graph`? I.e. how to get `6` in stead of `(6,6)`: ``` qplot(mpg, wt, data = mtcars, colour = as.factor(cyl), fill = as.factor(cyl)) ``` [](http://i.stack.imgur.com/GyMZt.jpg) ``` ggplotly() ``` [](http://i.stack.imgur.com/8ABJV.jpg)
Activity
cpsievert commentedon May 4, 2016
plotmath expressions aren't yet possible. #375 will have to be fixed first.
For question 2, at least in this example, you could avoid the redundant mapping
[-]`ggplotly`, plotmath expressions and double labels in legend[/-][+]Translate plotmath expressions[/+]cpsievert commentedon Apr 6, 2017
Perhaps
simsalapar::expr2latex(), or it's source, would be useful herecpsievert commentedon May 16, 2019
Can maybe borrow ideas from https://adv-r.hadley.nz/translation.html#latex
See also https://advanced-r-solutions.rbind.io/translating-r-code.html