r-plotly

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

筅森魡賤 提交于 2021-02-18 17:10:09
问题 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:09:38
问题 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

Format numbers on axes and tooltips in ggplotly

▼魔方 西西 提交于 2021-02-17 04:52:07
问题 I have used sprintf and formatC to take a double value and round it to two decimal places. However, when I go to use it in ggplot and ggplotly, it makes my visuals act out. Dput: structure(list(Date = structure(c(18328, 18329, 18330, 18331, 18332, 18333), class = "Date"), State = c("Louisiana", "Louisiana", "Louisiana", "Louisiana", "Louisiana", "Louisiana"), variablename1 = c(0, 0, 1, 1, 6, 14), variablename2 = c(5, 5, 5, 11, 37, 37), death = c(0, 0, 0, 0, 0, 0), variablename3 = c(5, 5, 6,

Adding Multiple “sliders” to the same Graph

你。 提交于 2021-02-16 15:25:31
问题 I am using the R programming language. Using the "plotly" library, I was able to make the following interactive graph: library(dplyr) library(ggplot2) library(shiny) library(plotly) library(htmltools) library(dplyr) #generate data set.seed(123) var = rnorm(731, 100,25) date= seq(as.Date("2014/1/1"), as.Date("2016/1/1"),by="day") data = data.frame(var,date) vals <- 90:100 combine <- vector('list', length(vals)) count <- 0 for (i in vals) { data$var_i = i data$new_var_i = ifelse(data$var >i,1,0

How to control “count” in tooltip for ggplotly with filled bar plot in R

泄露秘密 提交于 2021-02-11 18:01:46
问题 Thanks in advance for any advice you can offer! I'm hoping to be able to relabel "count" in the tooltip for a public facing interactive plot. Here's a reproducible example: library(plotly) df <- data.frame(cat=c(rep("A", 5), rep("B", 7), rep("C", 10)), time=c(rep("Time1", 3), rep("Time2", 13), rep("Time3", 6))) ggplotly(ggplot(df, aes(x=time, fill=cat)) + geom_bar(position = "fill")) I know I can control the time and category labels in the tooltip with text=paste("Category:", cat, "Time:"

How to control “count” in tooltip for ggplotly with filled bar plot in R

浪尽此生 提交于 2021-02-11 18:01:05
问题 Thanks in advance for any advice you can offer! I'm hoping to be able to relabel "count" in the tooltip for a public facing interactive plot. Here's a reproducible example: library(plotly) df <- data.frame(cat=c(rep("A", 5), rep("B", 7), rep("C", 10)), time=c(rep("Time1", 3), rep("Time2", 13), rep("Time3", 6))) ggplotly(ggplot(df, aes(x=time, fill=cat)) + geom_bar(position = "fill")) I know I can control the time and category labels in the tooltip with text=paste("Category:", cat, "Time:"

Customizing bin widths in plotly's histogram function in R

╄→гoц情女王★ 提交于 2021-02-11 15:30:08
问题 I have a dataset that dates and call volume per day. When I plotted them using the plotly R package, all except for 1 of them had each date separated into a different bin. However, this one tricky subset of the data instead grouped bins into 2 day intervals, which isn't very useful information. I'm sure it's an easy fix, but I'm not quite sure how to change the bin width. a <- as.Date(c("2019-02-01", "2019-01-14", "2019-01-15", "2019-01-24", "2019-01-31", "2019-01-22","2019-01-14", "2019-01

plotly: exposing the “config” object in the stored JSON string, for easier use with Plotly.JS functions

大城市里の小女人 提交于 2021-02-11 12:33:33
问题 I don't know whether this is a plotly question or an htmlwidgets question. Maybe it's both. I am using R to make plotly widgets, which are -- when made from R -- also htmlwidgets. When making plotly widgets in this way, the resulting HTML contains a stringified JSON object that includes the data and some settings for the widget. But only some parts of this JSON object are easily accessed from a Javascript console. For example, the "data" and "layout" objects are easily accessed, but the

Place Plotly Bar Chart and Box Plot in Front of Line Traces

那年仲夏 提交于 2021-02-10 14:26:36
问题 I have created subplots in Plotly that each contain a bar chart (or boxplot ) and three trace lines. I have created traces at y= 1,2,3 to act as ablines like in ggplot . What the plots look like: and . Problem: I want to have it so the bars of the bar chart are in front of the trace lines so you should only be able to see the trace lines in between the bars. My code currently: (I have excluded the code that generates the subplots as I don't think it is needed) generate_plotly_barPlot <-

Place Plotly Bar Chart and Box Plot in Front of Line Traces

て烟熏妆下的殇ゞ 提交于 2021-02-10 14:25:42
问题 I have created subplots in Plotly that each contain a bar chart (or boxplot ) and three trace lines. I have created traces at y= 1,2,3 to act as ablines like in ggplot . What the plots look like: and . Problem: I want to have it so the bars of the bar chart are in front of the trace lines so you should only be able to see the trace lines in between the bars. My code currently: (I have excluded the code that generates the subplots as I don't think it is needed) generate_plotly_barPlot <-