plotly

How to custom or display modebar in plotly?

强颜欢笑 提交于 2019-11-28 04:43:49
问题 I would like to custom the modebar (on top right) so as to keep just "zoom","pan","box select","zoom in" and "zoom out". If it's not possible, I prefer display the modebar. Here graph and code : x <- c(1:15) y <- c(1:15) xy <- as.data.frame(cbind(x,y)) example <- ggplot(data = xy,aes(x = x,y = y))+geom_line() ggplotly(example) Thank you for help 回答1: Using your example: x <- c(1:15) y <- c(1:15) xy <- as.data.frame(cbind(x,y)) example <- ggplot(data = xy,aes(x = x,y = y))+geom_line() ggplotly

plotly - different colours for different surfaces

妖精的绣舞 提交于 2019-11-28 04:25:30
问题 Using plotly I would like to have each surface to have different colour. library(plotly) t1 <- seq(-3, 3, 0.1); t2 <- seq(-3, 3, 0.1) p1 <- matrix(nrow = length(t1), ncol = length(t2)) p2 <- matrix(nrow = length(t1), ncol = length(t2)) p8a1 <- 1.2 p8a2 <- 1 p8d <- -1 p8b1 <- 0.7 p8b2 <- 0.6 for (i in 1:length(t2)) { for (j in 1:length(t1)) { p1[i, j] <- 1 / (1 + exp(-1.7 * (p8a1 * t1[j] + p8a2 * t2[i] + p8d))) p2[i, j] <- (1 / (1 + exp(-1.7 * p8a1 * (t1[j]- p8b1)))) * (1 / (1 + exp(-1.7 *

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

◇◆丶佛笑我妖孽 提交于 2019-11-28 02:27:57
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") %>% add_lines(x = ~hour, y = ~lft, name = "Lft", yaxis = "y2", colour = "red") %>% layout(title =

R Shiny ggplot bar and line charts with dynamic variable selection and y axis to be percentages

与世无争的帅哥 提交于 2019-11-28 02:24:00
I am learning Shiny and wanted help on a app that I am creating. I am creating an app that will take dynamic inputs from the user and should generate bar and line charts. I managed to create the bar chart but it is generating incorrect result. What I am looking for is variable selected in row should be my x-axis and y-axis should be percentage . scale to be 100%. column variable should be the variable for comparison and for that I am using position = "dodge" . My data is big and I have created a sample data to depict the situation. Since actual data is in data.table format I am storing the

Use a custom icon in plotly's pie chart in R

孤街醉人 提交于 2019-11-28 02:10:20
问题 I was wondering if there's a way to have a custom icon for plotly's pie chart instead of the usual pie division As of now I'm displaying the gender information using a pie chart which looks as below: I'm trying to make it look like the gender plot in the link below: https://app.displayr.com/Dashboard?id=c1506180-fe64-4941-8d24-9ec4a54439af#page=3e133117-f3b2-488b-bc02-1c2619cf3914 The plotly code is as under: plot_ly(genderselection, labels = ~Gender, values = ~Freq, type = 'pie') %>% layout

Plotly charts in a for loop

两盒软妹~` 提交于 2019-11-28 01:58:53
问题 I am converting ggplot2 charts using plotly and putting them in a knitr html output. Here is a working copy of the report. http://rpubs.com/kausti/NSEFO-23-Mar-2016 The first chart is plotly chart and the following ones are not. I would like them to be plotly charts but I am stuck. In the code below, plotChart function returns a ggplot2 plot. This code works! for (tick in tradeOps$ticker) { tmpDF = filter(tradeOps, ticker == tick) p = plotChart(tick = tick,Entry = tmpDF$Entry, Target = tmpDF

R plotly: how to observe whether a trace is hidden or shown through legend clicks with multiple plots

丶灬走出姿态 提交于 2019-11-28 01:44:09
I am trying to figure out which traces the user hides from a scatter plot by means of deselecting them in the interactive legend of plotly. I have read this SO post, and the similar questions linked in the comments below and this brought me closer to the solution The current solution is only doing partially what I need. Two things I am looking for to improve it is: - how to see which plot's legend is clicked (looking at source 'id' ?) - I can now see that a legend entry is clicked, but I need to be able to see whether it is clicked 'ON'(show trace) or 'OFF' The output i'm looking for would

Exporting PNG files from Plotly in R

十年热恋 提交于 2019-11-27 23:01:12
How can I export a Plotly chart as a image from R using code? (Not using the export button on the chart). For example, this code from the Plotly site, create this chart: library(plotly) set.seed(100) d <- diamonds[sample(nrow(diamonds), 1000), ] plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity), mode = "markers", color = carat, size = carat) How can I save it as a image? The official site has this material in python, but I didn't find something similar in R. In the Plotly docs in CRAN I discovered the function plotly_IMAGE . Here is a example: set.seed(100) d <- diamonds

Ordering in r plotly barchart

霸气de小男生 提交于 2019-11-27 22:57:40
Why do I get the different order in plotly bar chart than I defined in x and y variables. E.g. library(plotly) plot_ly( x = c("giraffes", "orangutans", "monkeys"), y = c(20, 14, 23), name = "SF Zoo", type = "bar" ) I need bar chart where I see bars in the same order as x variable (categorical) is defined. Is there any trick for that? plotly does it in alphabetical order. If you want to change it, just try to change levels of factor. This would be possible if you give your data in the form of data.frame like here: library(plotly) table <- data.frame(x = c("giraffes", "orangutans", "monkeys"), y

Customise the infoWindow / tooltip in R --> plotly

狂风中的少年 提交于 2019-11-27 19:03:21
问题 I am new to plot.ly and I just drew my first scatter plot out of R the other day - its great! testplot <- ggplot(a, aes(OR_Edu, OR_Illn, color=Country, size=total)) + geom_point() py$ggplotly(testplot) https://plot.ly/~SyTpp/14/or-illn-vs-or-edu/ Now, I would like to change the tooltip or the little info window that pops up on hover over a datapoint. In this case I am not interested in the y-coordinate but instead I would like to display the country name and the population size, which I