Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotly_r has deprecated orca and now uses kaleido #71

Open
cysouw opened this issue Aug 2, 2024 · 7 comments
Open

plotly_r has deprecated orca and now uses kaleido #71

cysouw opened this issue Aug 2, 2024 · 7 comments
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed

Comments

@cysouw
Copy link

cysouw commented Aug 2, 2024

I was just experimenting for the first time with this phenomenal filter and noted the following problems:

  • the plotly library in R has deprecated the orca function for static image export and replaced it with kaleido.
  • when using format=HTML the htmlwidget is taking over the whole page, not showing any of the remaining markdown document.

Just for reference: this is the markdown I was experimenting with (macOS 14.5, R 4.4.0):

# Test

This is a test

    ```{.ggplot2 format=SVG}
ggplotify::as.ggplot(~
  plot(1:10,10:1)
)
    ```

More text

    ```{.plotly_r format=HTML caption="plotly widget"}
library(plotly)
plot_ly(economics, x = ~pop)
    ```

blablabla
@LaurentRDC
Copy link
Owner

Let me tackle the first point, orca deprecation.

Under the hood, pandoc-plot extends your script until it looks like this:

pdf(NULL) # prevent the creation of an empty pdf

# Start of the user plot
library(plotly)
plot_ly(economics, x = ~pop)

# Capture the plot
library(plotly) # just in case
if (!require("processx")) install.packages("processx")
orca(last_plot(), file = "<filename>")

I'm not familiar with the R programming language and the plotly library; how should the script above be modified?


Regarding your second point, exporting to HTML. The script will be extended slightly differently, to this:

# Start of the user plot
library(plotly)
plot_ly(economics, x = ~pop)

# Capture the plot
library(plotly) # just in case
library(htmlwidgets)
p <- last_plot()
htmlwidgets::saveWidget(as_widget(p), "<filename.html>")

How should this script be modified so that the widget is not taking over the whole page?

@LaurentRDC
Copy link
Owner

Plotly's documentation still refers to orca; where can I see this deprecation notice?

@cysouw
Copy link
Author

cysouw commented Aug 8, 2024

Indeed, sorry. In the R-help it says "superseded by kaleido", but orca should still work. I'll try to get it running on my side, sorry.

https://www.rdocumentation.org/packages/plotly/versions/4.10.4/topics/orca

@cysouw
Copy link
Author

cysouw commented Aug 8, 2024

As for the Plotly-html output: what you are currently doing will produce a standalone HTML page. I have not been able to find what the Rmarkdown people are doing to include them into the markdown. I will research further, but I'm also not a specialist in such problem :-(

all the best with this project! I really like this approach.

@cysouw
Copy link
Author

cysouw commented Aug 8, 2024

A possible solution is to embed the resulting html-file into an iframe. Pandoc should be able to just include such a html-tag:

<iframe src = ""></iframe>

@cysouw
Copy link
Author

cysouw commented Aug 8, 2024

some more research turned up this suggestion: htmltools::tags$iframe(src = "filename")

https://plotly-r.com/saving

@LaurentRDC
Copy link
Owner

Awesome, thanks for taking the time to do the research.

I don't have the time to work on this these days, but I am happy to review pull requests

@LaurentRDC LaurentRDC added documentation Improvements or additions to documentation help wanted Extra attention is needed labels Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants