Comments (14)
I can not get the embedded iframes to work, tried both RStudio's 'knit html' button and knit(). Trying to replicate this: http://ropensci.org/blog/2014/04/17/plotly/.
Here's my sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin13.1.0 (64-bit)
locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] digest_0.6.4 htmltools_0.2.6 rmarkdown_0.3.10 tools_3.1.1 yaml_2.1.13
from plotly.r.
Hello @ouzor !
Follow the syntax below when writing your .Rmd
file:
You want to set the session
parameter to "knitr"
in the ggplotly()
call and also add the plotly=TRUE
option in the code chunk where you embed a Plotly plot.
Hope this helps!
from plotly.r.
Hm, I am not an expert in writing knit hooks, so do you have any ideas? In
practice I just use the knit html button in rstudio. The other context is
just using knit2html on the R command line?
Another thing that would be nice but I don't have any idea how to do is to
change the knit hook to automatically detect and embed plotlys (rather than
having to specify plotly=TRUE), any idea how to do that?
On Fri, Apr 18, 2014 at 2:13 AM, Scott Chamberlain <[email protected]
wrote:
Or at least for some people the hook only works when pressing knit html
button in rstudio.Perhaps we need to edit the knit hook to make it work in any context.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/12
.
from plotly.r.
When knitting from the command line, interactive()
is true.
pub$ggplotly <- function(gg=last_plot()){
if(!is.ggplot(gg)){
stop("gg must be a ggplot")
}
pargs <- gg2list(gg)
if(interactive()){ # we are on the command line.
resp <- do.call(pub$plotly, pargs)
browseURL(resp$url)
invisible(list(data=pargs, response=resp))
}else{ # we are in knitr/RStudio.
do.call(pub$iplot, pargs)
}
}
Not sure how to get around this. Interactivity seems to be a property of the session. Is it possible to create a new non-interactive session from within the console?
from plotly.r.
@ouzor Note that after clicking "Knit HTML" I also had to "Open in Browser" in order to see the embedded Plotly plot. The plot was generated (you can check online in your Plotly account), it's just a rendering thing.
from plotly.r.
Thanks @mkcor, this works! I was not able to find much documentation for the ggplotly command, is that available somewhere?
from plotly.r.
@ouzor We are indeed behind with respect to documentation.
Now this is documented here: http://blog.plot.ly/post/106630252117/plot-with-ggplot2-and-plotly-within-knitr-reports
Thank you for your patience!
from plotly.r.
Thanks!
I made a short comparison of different interactive visualization packages in R, including plotly, see here: http://ouzor.github.io/blog/2014/11/21/interactive-visualizations.html
I like very much the idea of turning an existing ggplot2 object to a nice interactive version. However, as a data scientist I work a lot with confidential data and can not make any of that public, which to me seems that I can not use the free version of plotly at all...
from plotly.r.
Hi @ouzor
We definitely understand that’s a concern. Thanks for asking. A couple thoughts.
You control the privacy of your data, and can make your work public or keep it private (like Google Docs or GitHub).
You own your data; we don’t make an IP claim to it. We also have an on-premise version of plotly you can run on your own servers. Would any of these options work? Let me know if we can help with anything.
from plotly.r.
Thanks a lot @mkcor, I'll take a closer look at these options!
from plotly.r.
why does this not work??
library(shiny)
library(plotly)
Rely on the 'WorldPhones' dataset in the datasets
package (which generally comes preloaded).
library(datasets)
Define a server for the Shiny app
shinyServer(function(input, output) {
Fill in the spot we created for a plot
output$phonePlot <- renderPlotly({
# Render a barplot
gg <- barplot(WorldPhones[,input$region]*1000,
main=input$region,
ylab="Number of Telephones",
xlab="Year")
})
p <- ggplotly(gg,session="knitr")
p
})
from plotly.r.
Despite following @mkcor's fix that seemed to work for @ouzor, I run into the listed error msg when running Knit HTML and when executing the code line-by-line from inside RStudio.
require(ggplot2)
gg <- ggplot(cars) + geom_point(aes(speed, dist))
gg
require(plotly)
py <- plotly("aniruhil", "maskedkey")
py$ggplotly(gg, session="knitr")
Quitting from lines 27-30 (testingplotly.Rmd)
Error in eval(expr, envir, enclos) : attempt to apply non-function
Calls: ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution haltedfrom plotly.r.
The interface has changed quite a bit since this thread first started. You should only need this:
library(plotly)
gg <- ggplot(cars) + geom_point(aes(speed, dist))
ggplotly(gg)
from plotly.r.
thanks Carson
from plotly.r.
Related Issues (20)
- Plots not showing in Rstudio Viewer HOT 6
- Categorical ggplotly legend no longer interpreted as categorical when two aesthetics are used HOT 1
- Change default plot height from 450px to something user-selected.
- Missing legend for mesh3d unless surface is added
- ggplotly is not working properly with scale_fill_binned
- `ggplotly()` gives subscript error with latest ggplot2
- Update plotly.js? HOT 1
- Incomplete documentation for `plot_ly`
- eom_GeomArcBar() has yet to be implemented in plotly
- plotly cannot handle Inf or -Inf when plotting
- implement geom_GeomStrippedCols() to be used with plotly
- Implement geom_rain and stat_halfeye into ggplotly
- labels in scale_color_manual() are ignored
- Plot_ly sunburst restyle event puts sunburst in weird state
- Hover incorrect when supplying color as argument in add_trace
- Unable to see x axis labels completely
- Warning message when creating a grouped boxplot
- Plots seem merged when using `subplot` in `plotly`
- Top and Bottom plots seem to have less spacing when using `subplot` in `plotly` HOT 1
- `updatemenus` > `buttons` don't behave as expected when restyling `y` axis (ignores `color` channel)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plotly.r.