plotly

Convert ggplot object to plotly in shiny application

此生再无相见时 提交于 2019-11-29 01:26:15
I am trying to convert a ggplot object to plotly and show it in a shiny application. But I encountered an error "no applicable method for 'plotly_build' applied to an object of class "NULL"" I was able to return the ggplot object to the shiny application successfully, output$plot1 <- renderplot({ gp <- ggplot(data = mtcars, aes(x = disp, y = cyl)) + geom_smooth(method = lm, formula = y~x) + geom_point() + theme_gdocs() }) but somehow plotly cannot convert it. My code looks like this output$plot2 <- renderplotly({ gp <- ggplot(data = mtcars, aes(x = disp, y = cyl)) + geom_smooth(method = lm,

Using R and plot.ly - how do I script saving my output as a webpage

偶尔善良 提交于 2019-11-28 22:02:03
问题 I want to make some interactive graphs using R and plot.ly. When I run the following code in R-Studio, it produces an interactive graph. library(plotly) set.seed(100) d <- diamonds[sample(nrow(diamonds), 1000), ] plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity), mode = "markers", color = carat, size = carat) After producing this graph, when I click on the "Export" button in the Plot window of R-Studio, it gives me the option to save the plot as a webpage. How can I script

Plotly as png in knitr/rmarkdown

送分小仙女□ 提交于 2019-11-28 20:36:46
问题 The following Rmarkdown renders the plotly 3D graph in HTML, but not in PDF. Testing plotly ```{r} library(plotly) p <- plot_ly(data=iris, x=~Sepal.Length, y=~Sepal.Width, z=~Petal.Length, color=~Species, symbols=c(0,1), type="scatter3d", mode="markers") p ``` A snapshot of the graph appears as follows: According to the plotly help page: If you are using rmarkdown with HTML output, printing a plotly object in a code chunk will result in an interactive HTML graph. When using rmarkdown with non

Date format in hover for ggplot2 and plotly

被刻印的时光 ゝ 提交于 2019-11-28 19:58:01
I have a question about date formats in plotly . I made a time series plot in ggplot2 that I'm trying to visualize with plotly but a format issue for date-time appears on the hover (see image). I would like the date format to be YYMMD-hh:mm . How could I get this format? Relevant R code on my script: library(lubridate) datosO3.melt <- melt(datosO3.plot, id.vars="fecha", value.name="value") ozono.plot <- ggplot() + geom_line(data=datosO3.melt, aes(x=fecha, y=value, colour=variable)) ggplotly(ozono.plot) The point is that column fecha in the dataframe is a date-time object created in a previous

Using plotly without online plotly account

*爱你&永不变心* 提交于 2019-11-28 18:16:54
Is it possible to use the plotly library to create charts in python without having an online plotly account? I think the code is opensource https://github.com/plotly/plotly.py . I would like to know whether we can use this without an online account. Yes, it can be done. The only purpose of having a plotly account is to host the graphs in your plotly account. Plotly Offline allows you to create graphs offline and save them locally. Instead of saving the graphs to a server, your data and graphs will remain in your local system. You can work offline without having a plotly account. The plotly

Customizing the sankey chart to cater large datasets

隐身守侯 提交于 2019-11-28 14:50:42
kindly run the script below, I have created a Sankey chart in R and plotly using data from "patients" dataset of the bupaR library. Please see the snapshot for reference. The issue I am facing is that, this custom plot has been built by declaring and building each and every relationship between users("r1","r2",etc.) and activities("Registration","X-Ray, etc). If I have a large number of users and activities, it will become a very tedious task to declare each and every relation. Please help me in modifying the plot dynamically such that I can replicate the code for large number of users and

Displaying data in the chart based on plotly_click in R shiny

我的未来我决定 提交于 2019-11-28 14:50:39
Please run this script below, the following R script gives a shiny dashboard with two boxes. I want to reduce the width between two boxes and display data in the right chart. The data should be based on the on click event that we see in the ggplotly function. Also plotly can be used to do the job, I guess. I want the code to fast and efficient at the same time. ## app.R ## library(shiny) library(shinydashboard) library(bupaR) library(eventdataR) library(lubridate) library(dplyr) library(XML) library(edeaR) library(xml2) library(data.table) library(ggplot2) library(ggthemes) library(glue)

why graph is getting blank after dragging it

余生长醉 提交于 2019-11-28 11:55:13
问题 When I'm dragging(expanding) multiple times then graphs coming blank. I referred this code. I want to plotly graph should work likeHigh Cahrt line graph. In high chart when we drag 4-5 times then its stop zoom-in graph and not getting blank graph. I want to stop it. I don't want blank. I didn't get how to stop it. Before dragging graph like this: After dragging multiple times graph coming like following: My code is: <script> var server1 = ['server1','server1','server1','server1','server1',

How to save Plotly Offline graph in format png?

怎甘沉沦 提交于 2019-11-28 11:23:33
I am using Plotly offline to generate graph in python. As per the documentation below, https://plot.ly/python/offline/ Here is my code, which perfectly generates C:/tmp/test_plot.html file. import plotly.offline as offline offline.init_notebook_mode() offline.plot({'data': [{'y': [4, 2, 3, 4]}], 'layout': {'title': 'Test Plot', 'font': dict(family='Comic Sans MS', size=16)}}, auto_open=False, filename='C:/tmp/test_plot') How can I save this graph as png instead of html? Anil_M offline.plot method has image='png and image_filename='image_file_name' attributes to save the file as a png . offline

In R plotly subplot graph, how to show only one legend?

北城余情 提交于 2019-11-28 11:16:11
I have a basic subplot with two graphs, both have a legend by default, but I want to see only one of them. I tried this : require(plotly) p1 <- plot_ly(data=iris,x=~Sepal.Length,y=~Sepal.Width,split=~Species) %>% layout(showlegend = FALSE) p2 <- plot_ly(data=iris,x=~Sepal.Length,y=~Sepal.Width,split=~Species) %>% layout(showlegend = TRUE) subplot(p1,p2) subplot(p2,p1) But it doesn't work : it seems as if only one showlegend attribute was handled, so if I start with p1 I have two legend, if I start with p2 I have two. Any ideas ? The above answer results in a minor problem. The legend is only