plotly

Shiny: How to change the shape and/or size of the clicked point?

旧街凉风 提交于 2019-12-02 11:58:03
问题 I would like to change the shape and size of the clicked point in the below plot. How to achieve it? For this toy plot, I have reduced the number of points from original 100k to 2k. So, the expected solution should be highly scalable and do not deviate from the original plot i.e., all the colors before and after the update of the click point should be the same. library(shiny) library(plotly) df <- data.frame(X=runif(2000,0,2), Y=runif(2000,0,20), Type=c(rep(c('Type1','Type2'),600), rep(c(

How do I plot Linear Regression?

。_饼干妹妹 提交于 2019-12-02 11:47:22
问题 I wish to learn how to use Plotly with Python for data analysis. I have been using this website as reference. My current code looks like this: from plotly import tools import plotly as py import plotly.graph_objs as go py.offline.init_notebook_mode(connected=True) # Create linear regression object regr = linear_model.LinearRegression() # Train the model using the training sets regr.fit(X_train, y_train) p1 = go.Scatter(x=X_test, y=y_test, mode='markers', marker=dict(color='black') ) p2 = go

Creating a horizontal bar chart in R to display sequence of activities

六月ゝ 毕业季﹏ 提交于 2019-12-02 11:09:21
The dataset "patients" is an eventlog of patients visiting a clinic and getting treatment. The script below gives a data frame with traces or sequence of activities in the eventlog, trace_id and absolute frequency of the cases following the particular trace. I wish to create a dynamic horizontal bar chart using ggplot2 or plotly such that the traces are represented like the snapshot attached with the absolute frequency in % at the top of the bar with axes labels. Thanks and please help! library("bupaR") traces(patients, output_traces = T, output_cases = F) Hope this helps (I am not able to get

Creating a dynamic chart displaying sequences of activities with their count in R

那年仲夏 提交于 2019-12-02 09:21:18
If you run the R script below, the dataset "patients" is an eventlog of patients visiting a clinic and getting treatment. The trace explorer gets created as in the snapshot below with the tooltip displayed. Now in the "#Script for Frequency Percentage", you get the frequency percentage for each trace in the column "af_percent". My requirement is that, I just want to replace the "label = value" in the ggplot command below with corresponding frequency percentage of each trace. Please help. library(splitstackshape) library(scales) library(ggplot2) library(plotly) tr <- data.frame(traces(patients,

Mysterious javascript bug that is depending on what plot object names are used in R shiny app

耗尽温柔 提交于 2019-12-02 09:01:16
问题 In the app below there is some weird mystery going on: Why can I not use certain names for my plots? The app was build as a dummy app to change the color of traces in plots. 1 button affects trace x in 2 plots, and there is one button for each trace. The button names contain the name of both plots, and the trace nr they target. When the plots are named plot1, plot2, plot3, plot4, it all works. but the actual program it is intended for uses different plot names. Changing all instances of plot1

trace order plotly R

六眼飞鱼酱① 提交于 2019-12-02 08:26:57
问题 I am trying to figure out how to control the order of the traces plotted in plotly, i.e. how to bring traces to the front and to the back. Here there is a simple piece of code that plots two traces. How can I decide the order? library(plotly) airquality_sept <- airquality[which(airquality$Month == 9),] airquality_sept$Date <- as.Date(paste(airquality_sept$Month, airquality_sept$Day, 1973, sep = "."), format = "%m.%d.%Y") plot_ly(airquality_sept) %>% add_trace(x = ~Date, y = ~Wind, type = 'bar

Cx_Freeze and Plotly

北城以北 提交于 2019-12-02 08:07:09
I am trying to build an exe of an application that uses plotly using cx_freeze. I have previously built the application using matplotlib but have switched the graphing over to plotly. I can build the application but when I try to plot, I get the following error. url = py.plot(fig, filename='pandas-box-plot') File "C:\Python34\lib\site-packages\plotly\offline\offline.py", line 284, in p lot get_plotlyjs(), File "C:\Python34\lib\site-packages\plotly\offline\offline.py", line 48, in ge t_plotlyjs plotlyjs = resource_string('plotly', path).decode('utf-8') File "C:\Python34\lib\site-packages\pkg

Set major tick labels to be displayed as scientific notation in a Plotly plot in R

两盒软妹~` 提交于 2019-12-02 07:49:30
问题 I'm trying to get plotly to put values in scientific notation regardless of their size, i.e. 100 should be 1E02 in the ticks, but it keeps showing numbers below 10.000 as normal annotation. Setting the format is done through exponentformat = "E" "but it only affects larger numbers. Here is an example code of how I write it: f2 <- list(family = "Old Standard TT, serif", size = 14, color = "black") ax <- list(showticklabels = TRUE, tickfont = f2, showgrid=F, zeroline=T, showline=T, nticks = 4,

R Shiny plotly update trace colors with javascript when colourInput is build in the server

亡梦爱人 提交于 2019-12-02 07:45:32
This is a modified version to the previous question here In this app (which reflects my real app better) the following situation happens: I have 2 sets of plots, - the 2 plots of a set show the same traces, just different columns plotted - each plot is on a different page in my app - The two plots should be linked to 1 set of colourInputs , on page 2 - The colourInputs are built in the server with renderUI *1 *1: for this reason, I believe that p %>% onRender(js) approach will not work as I saw earlier in THIS question for the YNbuttons there Goal: if colourInput 'COL_button_plot1_plot2_N'

Adding additional text to the hovertext label

萝らか妹 提交于 2019-12-02 07:34:15
问题 I've searched for some time now and I can't seem to find a related question. There are similar questions, but nothing that gets to the heart of what I am trying to do with the code I have. I am trying to add additional text to the hovertext in plotly. Here is my code so far: import pandas as pd import numpy as np from plotly.offline import * init_notebook_mode(connected=True) graph1 = merged.groupby(['study_arm', 'visit_label'])['mjsn'].mean().unstack('study_arm') graph1.iplot(mode='lines