r-plotly

Exporting PNG files from Plotly in R without internet

落花浮王杯 提交于 2019-12-01 04:46:30
In this question, Exporting PNG files from Plotly in R I asked how to export Plotly plots to disk. I used the function plotly_IMAGE , but later discovered that the function uses the Plotly internet servers. The question is, now that Plotly JavaScript is local, how can I create a png local file without internet? I tried this code, without success: library(plotly) png(filename = "test.png") plot_ly(x = 1:10) dev.off() The idea is to make it programaticaly, without click on export button over the chart. They've added a new export function to the plotly package. But to my knowledge it does the

Exporting PNG files from Plotly in R without internet

旧巷老猫 提交于 2019-12-01 01:11:47
问题 In this question, Exporting PNG files from Plotly in R I asked how to export Plotly plots to disk. I used the function plotly_IMAGE , but later discovered that the function uses the Plotly internet servers. The question is, now that Plotly JavaScript is local, how can I create a png local file without internet? I tried this code, without success: library(plotly) png(filename = "test.png") plot_ly(x = 1:10) dev.off() The idea is to make it programaticaly, without click on export button over

Removing traces by name using plotlyProxy (or accessing output schema in reactive context)

 ̄綄美尐妖づ 提交于 2019-11-30 23:31:37
I am attempting to use the plotlyProxy() functionality ( Documented here ) to allow users of a shiny application to add and remove traces with minimal latency. Adding traces proves to be relatively simple, but I'm having difficulty figuring out how to remove traces by name (I'm only seeing documented examples that remove by trace number) . Is there a way to remove traces by name using plotlyProxy() ? If not, is there a way that I can parse through the output object to derive what trace numbers are associated with a given name? I can determine the associated trace number of a given name in an

Removing traces by name using plotlyProxy (or accessing output schema in reactive context)

孤街醉人 提交于 2019-11-30 18:31:35
问题 I am attempting to use the plotlyProxy() functionality (Documented here) to allow users of a shiny application to add and remove traces with minimal latency. Adding traces proves to be relatively simple, but I'm having difficulty figuring out how to remove traces by name (I'm only seeing documented examples that remove by trace number) . Is there a way to remove traces by name using plotlyProxy() ? If not, is there a way that I can parse through the output object to derive what trace numbers

Download Plotly using downloadHandler

自作多情 提交于 2019-11-30 07:50:50
问题 i got stuck at some point while trying to use downloadHandler to download Plotly images. I just cannot figure out further how to get the image from temp directory... Here is a sample code: library(shiny) library(plotly) library(rsvg) library(ggplot2) d <- data.frame(X1=rnorm(50,mean=50,sd=10),X2=rnorm(50,mean=5,sd=1.5),Y=rnorm(50,mean=200,sd=25)) ui <-fluidPage( title = 'Download Plotly', sidebarLayout( sidebarPanel( helpText(), downloadButton('download'), tags$script(' document

plotly: Updating data with dropdown selection

一曲冷凌霜 提交于 2019-11-30 07:40:58
问题 I am not sure if this is possible, but here is what I would like to do. I would like to update the data in a plotly plot by selecting from a dropdown menu. As a simple example, let's assume I have a data frame df <- data.frame(x = runif(200), y = runif(200), z = runif(200)) from which I use df$x and df$y in a scatter plot. Two scenarios of data manipulation I would like to achieve using a dropdown: Replace df$y with df$z Plot only the first n values of df$x and df$y I looked at the following

Download Plotly using downloadHandler

女生的网名这么多〃 提交于 2019-11-29 05:18:24
i got stuck at some point while trying to use downloadHandler to download Plotly images. I just cannot figure out further how to get the image from temp directory... Here is a sample code: library(shiny) library(plotly) library(rsvg) library(ggplot2) d <- data.frame(X1=rnorm(50,mean=50,sd=10),X2=rnorm(50,mean=5,sd=1.5),Y=rnorm(50,mean=200,sd=25)) ui <-fluidPage( title = 'Download Plotly', sidebarLayout( sidebarPanel( helpText(), downloadButton('download'), tags$script(' document.getElementById("download").onclick = function() { var plotly_svg = Plotly.Snapshot.toSVG( document.querySelectorAll(

plotly: Updating data with dropdown selection

强颜欢笑 提交于 2019-11-29 05:09:40
I am not sure if this is possible, but here is what I would like to do. I would like to update the data in a plotly plot by selecting from a dropdown menu. As a simple example, let's assume I have a data frame df <- data.frame(x = runif(200), y = runif(200), z = runif(200)) from which I use df$x and df$y in a scatter plot. Two scenarios of data manipulation I would like to achieve using a dropdown: Replace df$y with df$z Plot only the first n values of df$x and df$y I looked at the following two examples, which I can easily reproduce: https://plot.ly/r/dropdowns/ However, I have no idea how to

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

Displaying image on point hover in Plotly

别说谁变了你拦得住时间么 提交于 2019-11-28 11:07:37
Plotly allows you to display text fields when hovering over a point on a scatterplot. Is it possible to instead display an image associated with each point when the user hovers over or clicks on it? I am mostly just using the web interface, but I could instead push my ggplot from R. Unfortunately, there is no easy way to display images on hover on plotly graphs at the moment. If you are willing to learn some javascript, plotly's embed API allows you to customize hover (as well as click) interactivity. Here is an example of a custom hover interaction showing images on top of a plotly graph. The