plotly

Selection of activity trace in a chart and display in a data table in R shiny

谁说胖子不能爱 提交于 2019-11-27 16:31:36
If you run the R shiny script below, you get two boxes in an R shiny dashboard, The chart on the left displays a plot for all the traces or set of activities that occur in the eventlog data "patients_eventlog". "patients2" is a data in the script that explains each and every case appearing in column "a1", and corresponding activities basides in column "a2". My requirement is that when I click anywhere on a particular trace in the chart on left, I should get the relevant columns "a1","a2" and "a3" with the data having only and only those cases in which the activities in that trace are occurring

Convert ggplot object to plotly in shiny application

落爺英雄遲暮 提交于 2019-11-27 14:53:48
问题 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

Flex items not shrinking when window gets smaller [duplicate]

孤街醉人 提交于 2019-11-27 13:28:15
问题 This question already has an answer here: Why don't flex items shrink past content size? 1 answer I'm trying to fit two plotly plots next to each other inside a CSS flexbox. I want them to resize when the window is resized. It works as expected when the window grows, but the plots don't shrink when the window gets smaller. var trace1 = {}; var trace2 = {}; var plotdiv1 = document.getElementById("plotdiv1"); var plotdiv2 = document.getElementById("plotdiv2"); Plotly.newPlot(plotdiv1, [trace1])

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

自作多情 提交于 2019-11-27 11:22:41
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 tried the option tooltip= but it's specified you can use the only variable describe in the aesthetic,

Displaying data in the chart based on plotly_click in R shiny

≡放荡痞女 提交于 2019-11-27 08:52:42
问题 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)

How to save Plotly Offline graph in format png?

风格不统一 提交于 2019-11-27 06:12:47
问题 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? 回答1: offline.plot

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

▼魔方 西西 提交于 2019-11-27 06:12:18
问题 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

How to give subtitles for subplot in plot_ly using R

99封情书 提交于 2019-11-27 05:45:36
问题 I am wondering how to give difference subtitles for the subplots using plot_ly. Any hint please. I got one title BB in this case. Thanks. p <- subplot( plot_ly(economics, x = date, y = uempmed)%>%layout(showlegend = FALSE, title="AA"), plot_ly(economics, x = date, y = unemploy)%>%layout(showlegend = FALSE, title="BB"), margin = 0.05 ) 回答1: The title attribute in layout refers to the title for the entire plotting surface, so there can only be one. However, we can use text annotations to create

Missing data when Supplying a Dual-axis--Multiple-traces to subplot

陌路散爱 提交于 2019-11-27 04:49:22
问题 Data is provided at the bottom of the question. I am trying to use subplot with plotly objects which one of them has multiple series in it. When I use subplot one of the series in the first graph does not show up in the final product. Look at the code below: library(plotly) library(dplyr) sec_y <- list(tickfont = list(color = "red"), overlaying = "y", side = "right", title = "Lft") pp1 <- fmean1 %>% group_by(grp) %>% plot_ly() %>% add_lines(x = ~hour, y = ~fmgd, name = "FMGD", colour = "blue"

Plotly notebook mode with google colaboratory

末鹿安然 提交于 2019-11-27 04:30:39
I am am trying out colaboratory with plotly notebook mode - I open a new notebook, copy and paste the following simple example from plotly's documentation, but don't see an output. There is a large blank in the output space where the plot whould normally be. This works fine in my local notebook (which is a newer version of plotly, but per their docs offline mode should work with the google colab version) Any ideas? import plotly from plotly.graph_objs import Scatter, Layout plotly.offline.init_notebook_mode(connected=True) plotly.offline.iplot({ "data": [Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])