r-plotly

One slider controlling multiple subplots in R

若如初见. 提交于 2021-02-20 02:46:49
问题 I want to use one slider to control multiple subplots created with plotly. I found answers in Python like these two: Plot.ly. Using slider control with multiple plots https://community.plot.ly/t/using-one-slider-to-control-multiple-subplots-not-multiple-traces/13955/4 Example (second link): import plotly.graph_objs as go from plotly.tools import make_subplots fig = make_subplots(1, 2) fig.add_scatter(y=[1, 3, 2], row=1, col=1, visible=True) fig.add_scatter(y=[3, 1, 1.5], row=1, col=1, visible

One slider controlling multiple subplots in R

大兔子大兔子 提交于 2021-02-20 02:45:50
问题 I want to use one slider to control multiple subplots created with plotly. I found answers in Python like these two: Plot.ly. Using slider control with multiple plots https://community.plot.ly/t/using-one-slider-to-control-multiple-subplots-not-multiple-traces/13955/4 Example (second link): import plotly.graph_objs as go from plotly.tools import make_subplots fig = make_subplots(1, 2) fig.add_scatter(y=[1, 3, 2], row=1, col=1, visible=True) fig.add_scatter(y=[3, 1, 1.5], row=1, col=1, visible

Looping through R Plotly with subplot and hiding all legend except one

和自甴很熟 提交于 2021-02-19 07:48:05
问题 I need to loop through i iteration of factors, and each factor needs to be plotted as one plot in a subplot. What I would like to do is hiding the legend for every iteration bar the first one, and use legendgroup to tie all the legends together. This is what I have done so far: library(plotly) library(dplyr) mtcars %>% mutate(vs = as.factor(vs)) %>% group_split(cyl) %>% lapply(function(i) { #show.legend <- ifelse(i == 1, TRUE, FALSE) show.legend <- if(i == 1) {TRUE} else {FALSE} plot_ly( data

Remove Gaps Between Bars in Plotly

谁说胖子不能爱 提交于 2021-02-19 05:30:50
问题 I am trying to create a Marimekko chart in R using Plotly. Essentially, this is just a stacked, variable-width bar chart with both bars directly adjacent to one another. Currently, my attempt looks like this: The code to create it is here: bar.test <- plot_ly(type = "bar") %>% layout(title = paste0("Newark Charter vs District BTO Makeup"), xaxis = list(title = ""), yaxis = list(title = "Percent BTO", tickformat = "%")) %>% add_trace(x = ~test1$sch.type, y = ~test1$y, width = ~test1$width,

Remove Gaps Between Bars in Plotly

送分小仙女□ 提交于 2021-02-19 05:30:15
问题 I am trying to create a Marimekko chart in R using Plotly. Essentially, this is just a stacked, variable-width bar chart with both bars directly adjacent to one another. Currently, my attempt looks like this: The code to create it is here: bar.test <- plot_ly(type = "bar") %>% layout(title = paste0("Newark Charter vs District BTO Makeup"), xaxis = list(title = ""), yaxis = list(title = "Percent BTO", tickformat = "%")) %>% add_trace(x = ~test1$sch.type, y = ~test1$y, width = ~test1$width,

Remove Gaps Between Bars in Plotly

左心房为你撑大大i 提交于 2021-02-19 05:30:09
问题 I am trying to create a Marimekko chart in R using Plotly. Essentially, this is just a stacked, variable-width bar chart with both bars directly adjacent to one another. Currently, my attempt looks like this: The code to create it is here: bar.test <- plot_ly(type = "bar") %>% layout(title = paste0("Newark Charter vs District BTO Makeup"), xaxis = list(title = ""), yaxis = list(title = "Percent BTO", tickformat = "%")) %>% add_trace(x = ~test1$sch.type, y = ~test1$y, width = ~test1$width,

plotly click events from anywhere on the plot

纵然是瞬间 提交于 2021-02-19 02:57:49
问题 I am new to r-plotly and trying to figure out how to handle clicks which are not on the data. It seems that using event_data("plotly_click") I get events that are on points from the data, but so far have not figured out how to do this for clicks which are not close to the data, but just on the white part of the plot. Shiny click events from plots can do this and I just get the x and y of the click. I want similar, but for plotly plots. Can I specify click events to be from anywhere on the

Open Link on Datapoint Click with Plotly in R Shiny

☆樱花仙子☆ 提交于 2021-02-18 19:01:19
问题 I'm working with Plotly in R to develop a Shiny web app. I've put together an interactive scatterplot and configured the hovertext with the information I want. My implementation is as follows: plot_ly(data=partition, x=~get(x), y=~get(y), color=~SenderS, colors="Set1", text=~paste("Link(s): <a href='", partition$Link,"'>", partition$Link, "</a>", "<br>Date: ", partition$Date, "<br>Parties: ", partition$SenderS, " to ", partition$Target, "<br>", x_og, ": ", partition[,x], "<br>", y_og, ": ",

Interactively change axis scale (linear/log) in Plotly image using R

此生再无相见时 提交于 2021-02-18 17:10:34
问题 Goal: To create interactive dropdown/buttons to update the axes' scale for a Plotly figure from R. Issue: There is a lot of documentation on creating buttons and log plots using layout and updatemenus ; however, it was difficult to find one that described how a button could be added specifically for changing the scale of the axes. Some posts on stackoverflow provided solutions for doing this in python but I struggled to find an equivalent one for R. I have provided a solution/example here

Interactively change axis scale (linear/log) in Plotly image using R

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-18 17:10:20
问题 Goal: To create interactive dropdown/buttons to update the axes' scale for a Plotly figure from R. Issue: There is a lot of documentation on creating buttons and log plots using layout and updatemenus ; however, it was difficult to find one that described how a button could be added specifically for changing the scale of the axes. Some posts on stackoverflow provided solutions for doing this in python but I struggled to find an equivalent one for R. I have provided a solution/example here