plotly

Optimizing add_trace() in a for loop?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 09:13:10
问题 I'm using the add_trace() function in a for loop to create lines for a 3d network graph in plotly's scatter3d mode. Each add_trace draws an individual line between two nodes in the network. The method is working, but with large number of loops, the speed of the individual loops seems to be slowing down very quickly. Example data can be downloaded here: https://gist.github.com/pravj/9168fe52823c1702a07b library(igraph) library(plotly) G <- read.graph("karate.gml", format = c("gml")) L <-

R Plotly: Cannot re-arrange x-axis when axis type is category

旧时模样 提交于 2019-12-18 06:29:05
问题 I have the following data: myData <- data.frame(FISCAL_YEAR_WEEK = c('2016-09','2016-09','2016-09','2016-09','2016-09','2016-10','2016-10','2016-10','2016-10','2016-10','2016-10','2016-10','2016-10','2016-11','2016-11','2016-11','2016-11','2016-12','2016-12','2016-12','2016-12','2016-12','2016-12','2016-14','2016-14','2016-14','2016-14'), MOTOR_VEND_ID = c('7','E','F','F','M','7','9','E','E','F','F','M','R','7','E','F','F','E','E','F','F','M','M','7','E','F','M'),HGA_SUPPLIER=c('RHO','RHO',

Plotly: add_trace in a loop

二次信任 提交于 2019-12-18 04:33:28
问题 I'm trying to add_trace ad each loop, but I get only one plot with multiplies lines on over each other. mean <- -0.0007200342 sd <- 0.3403711 N=10 T=1 Delta = T/N W = c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd))) t <- seq(0,T, length=N+1) p<-plot_ly(y=W, x=t) for(i in 1:5){ W <- c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd))) p<-add_trace(p, y=W) } print(p) 回答1: The plot_ly and add_trace functions have an evaluation = FALSE option that you can change to TRUE , which should fix

Using plotly without online plotly account

断了今生、忘了曾经 提交于 2019-12-17 23:36:31
问题 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. 回答1: 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

Date format in hover for ggplot2 and plotly

你说的曾经没有我的故事 提交于 2019-12-17 22:26:37
问题 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

Customizing the sankey chart to cater large datasets

社会主义新天地 提交于 2019-12-17 21:25:24
问题 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

R Shiny ggplot bar and line charts with dynamic variable selection and y axis to be percentages

梦想的初衷 提交于 2019-12-17 17:22:51
问题 I am learning Shiny and wanted help on a app that I am creating. I am creating an app that will take dynamic inputs from the user and should generate bar and line charts. I managed to create the bar chart but it is generating incorrect result. What I am looking for is variable selected in row should be my x-axis and y-axis should be percentage . scale to be 100%. column variable should be the variable for comparison and for that I am using position = "dodge" . My data is big and I have

R plotly: how to observe whether a trace is hidden or shown through legend clicks with multiple plots

最后都变了- 提交于 2019-12-17 16:55:26
问题 I am trying to figure out which traces the user hides from a scatter plot by means of deselecting them in the interactive legend of plotly. I have read this SO post, and the similar questions linked in the comments below and this brought me closer to the solution The current solution is only doing partially what I need. Two things I am looking for to improve it is: - how to see which plot's legend is clicked (looking at source 'id' ?) - I can now see that a legend entry is clicked, but I need

How to choose variable to display in tooltip when using ggplotly?

谁说我不能喝 提交于 2019-12-17 08:28:40
问题 I have a simple data frame: seq <- 1:10 name <- c(paste0("company",1:10)) value <- c(250,125,50,40,40,30,20,20,10,10) d <- data.frame(seq,name,value) And I want to plot it this way: require(ggplot2) ggplot(data = d,aes(x=seq,y=value))+geom_line() + geom_point() Now I want to use plotly, mostly to be able, when mousing over a point, to get other information than the value, such as the company name. I try this : require(plotly) ggplotly() which get me a tooltip, but with only seq and value. I

Second Y-Axis in a R plotly graph

做~自己de王妃 提交于 2019-12-14 04:18:24
问题 I combined 2 charts and I am trying to add the second y-axis, but every time I add the yaxis = "y2" to my code, I lose have the my bar graphs. > MediaDate Spend Search_Visits Other_Visits MediaDate2 > 2016-04-01 $39654.36 19970 2899 Apr 2016 > 2016-05-01 $34446.28 14460 2658 May 2016 > 2016-06-01 $27402.36 12419 2608 Jun 2016 my original code is: p <- plot_ly(x= w$MediaDate2,y=w$Search_Visits,name = "Paid Search", type = "bar") p2 <- add_trace(p, x=w$MediaDate2, y=w$Other_Visits,name = "Other