r-plotly

R Shiny + plotly : change color of a trace with javascript without affecting markers and legend in multiple plots

无人久伴 提交于 2019-12-04 05:47:42
问题 This is a follow up question based on THIS post. The demo app here is a closer representation of my more complex situation of my real shiny app that I'm trying to improve by replacing code that causes re- rendering of plotly objects by javascript codes that alter the existing plots . This app has: - 4 plots with unique ID's - sets of 2 plots listen to the same set of colourInputs , 1 for each trace in each plot - the legend and marker size in all plots are linked to numericInputs The

How to customize hover text for plotly boxplots in R

我怕爱的太早我们不能终老 提交于 2019-12-03 14:56:10
I understand how to customize the hover text for scatter plots in plotly , but box plots do not accept the 'text' attribute. Warning message: 'box' objects don't have these attributes: 'text' . I have over 300 x-axis variables and there are numbered samples(1-50) in two groups(A or B) that I want to plot together in the same box plot, then I'd like to differentiate between the sample numbers and groups through hover text when moving the cursor over outliers. I'd like to have my custom data labels instead of the automatic quartile labels. Is that possible with plotly boxplots? library(plotly)

Use plotlyProxy to add multiple traces when data changes

你离开我真会死。 提交于 2019-12-02 16:07:50
问题 Thank to this question: SO-Q I have now understood how to remove traces. In this case, I simply remove 0:2, but I can change that to i.e. array(O:unique(factor(df$group))) to remove however many groups my model had created in a previous run. What I haven't been able to figure out however, is how to add multiple traces, 1 for each factor in the target column, and color them by the colors in THECOLORS library("shiny") library("plotly") rock[,2] <- sample(c('A', 'B', 'C'), 48, replace = T)

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

与世无争的帅哥 提交于 2019-12-02 15:56:11
问题 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

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'

Is there a way to hide Trace Names in Plotly (specifically R)?

橙三吉。 提交于 2019-12-02 07:24:26
问题 I've been wracking my brain over how to get rid of the trace name with plotly and can't seem to find anything. It seems adding the trace name is a unique feature of plotly boxplots. I could just name it " " but I need the original trace name so that I can reference it when overlaying a marker. I've simplified the code as much as possible to the root issue. Is there a way to hide the trace name? housing = read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data

How can I combine a line and scatter on same plotly chart?

狂风中的少年 提交于 2019-12-02 01:21:45
The two separate charts created from data.frame work correctly when created using the R plotly package. However, I am not sure how to combine them into one (presumably with the add_trace function) df <- data.frame(season=c("2000","2000","2001","2001"), game=c(1,2,1,2),value=c(1:4)) plot_ly(df, x = game, y = value, mode = "markers", color = season) plot_ly(subset(df,season=="2001"), x = game, y = value, mode = "line") Thanks in advance There are two main ways you can do this with plotly, make a ggplot and convert to a plotly object as @MLavoie suggests OR as you suspected by using add_trace on

Is there a way to hide Trace Names in Plotly (specifically R)?

北城余情 提交于 2019-12-02 00:07:01
I've been wracking my brain over how to get rid of the trace name with plotly and can't seem to find anything. It seems adding the trace name is a unique feature of plotly boxplots. I could just name it " " but I need the original trace name so that I can reference it when overlaying a marker. I've simplified the code as much as possible to the root issue. Is there a way to hide the trace name? housing = read.table("http://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data") colnames(housing) = c("CRIM","ZN","INDUS","CHAS","NOX","RM","AGE","DIS","RAD","TAX","PTRATIO","B",

Plotly in R: format axis - tick labels to percentage

感情迁移 提交于 2019-12-01 16:30:19
I am creating bar charts in plotly with y-axis representing percentages or shares within 0-1. The y-axis displays as 0.05 instead of 5.0%. Is there a way to display y-axis tick labels as %## ? I have tried using tickformat = "%" but that doesn't seem to be working. You can do this in plotly using layout : p <- p %>% layout(yaxis = list(tickformat = "%")) Or if you want to only add % and do not reformat the numbers then: p <- p %>% layout(yaxis = list(ticksuffix = "%")) Example: This is an example that shows how to edit the y axis ticks as you wish. (like multiply by a number and add suffix,

Plotly in R: format axis - tick labels to percentage

最后都变了- 提交于 2019-12-01 14:19:55
问题 I am creating bar charts in plotly with y-axis representing percentages or shares within 0-1. The y-axis displays as 0.05 instead of 5.0%. Is there a way to display y-axis tick labels as %## ? I have tried using tickformat = "%" but that doesn't seem to be working. 回答1: You can do this in plotly using layout : p <- p %>% layout(yaxis = list(tickformat = "%")) Or if you want to only add % and do not reformat the numbers then: p <- p %>% layout(yaxis = list(ticksuffix = "%")) Example: This is