Questions tagged [r-plotly]

plotly is an R package to create interactive web-based visualizations via 'plotly.js'.

plotly is a plotting package for R used to create interactive data visualizations. For examples and documentation, visit the plotly website here.

Repository

Stable Version on Cran

1205 questions
58
votes
4 answers

How to choose variable to display in tooltip when using ggplotly?

I have a simple data frame: seq <- 1:10 name <- c(paste0("company",1:10)) value <- c(250,125,50,40,40,30,20,20,10,10) d <- data.frame(seq,name,value) And I want to plot it this way: require(ggplot2) ggplot(data = d,aes(x=seq,y=value))+geom_line() +…
Malta
  • 1,883
  • 3
  • 17
  • 30
26
votes
2 answers

Format axis tick labels to percentage in plotly

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…
Binny
  • 263
  • 1
  • 3
  • 7
24
votes
2 answers

Displaying image on point hover in Plotly

Plotly allows you to display text fields when hovering over a point on a scatterplot. Is it possible to instead display an image associated with each point when the user hovers over or clicks on it? I am mostly just using the web interface, but I…
half-pass
  • 1,851
  • 4
  • 22
  • 33
21
votes
1 answer

date format in tooltip of ggplotly

I am using ggplotly to show an interactive time-series plot. The x axis is in date format, yet the hover tool tip in plotly is converting the date format to a numeric (screenshot attached). Any ideas on how to get the date to show as a proper date…
user5831311
  • 273
  • 2
  • 8
18
votes
4 answers

R + plotly: solid of revolution

I have a function r(x) that I want to rotate around the x axis to get a solid of revolution that I want to add to an existing plot_ly plot using add_surface (colored by x). Here is an example: library(dplyr) library(plotly) # radius depends on x r…
mschilli
  • 1,884
  • 1
  • 26
  • 56
17
votes
1 answer

plotly stacked bar chart with over 100 categories

I have a dataset that contains over 100 categories. If I am going to plot it, I have to write over 100 lines code for it. Here is the example from plotly official website: library(plotly) Animals <- c("giraffes", "orangutans", "monkeys") SF_Zoo <-…
Eleanor
  • 2,647
  • 5
  • 18
  • 30
17
votes
2 answers

How to set plotly chart to have a transparent background in R?

Here's what I have, so far: f1 <- list( family = "Arial, sans-serif", size = 25, color = "white" ) f2 <- list( family = "Old Standard TT, serif", size = 14, color = "black" ) a <- list( title = "SALES PER SONG", titlefont =…
POW123
  • 316
  • 1
  • 3
  • 12
16
votes
1 answer

Getting separate axis labels on R plotly subplots

When using the R plotly package version 4.5.6 I haven't been able to figure out how to get axis labels to appear when combining multiple plots using subplot. Here is an example where no x-axis labels appear. require(plotly) a <- data.frame(x1=1:3, …
Frank Harrell
  • 1,954
  • 2
  • 18
  • 36
15
votes
1 answer

How to facet a plot_ly() chart?

Using ggplot2 and plotly to make an interactive scatter plot with facet_wrap(). library(ggplot2) library(plotly) g<-iris%>% ggplot(aes(x = Sepal.Length, y = Sepal.Width, color = Species))+ geom_point()+ …
M.Viking
  • 5,067
  • 4
  • 17
  • 33
15
votes
2 answers

How to remove duplicate legend entries w/ plotly subplots()

How can I remove the duplicates in my legend when using plotly's subplots()? Here is my MWE: library(plotly) library(ggplot2) library(tidyr) mpg %>% group_by(class) %>% do(p = plot_ly(., x = ~cyl, y = ~displ, color = ~trans, type = 'bar'))…
blabbath
  • 442
  • 7
  • 27
15
votes
2 answers

R plotly subplot add space between plots

I want to add space between plots but when I play with margin, it either overlaps or cuts. Here is the code: library(plotly) plotList <- function(nplots) { lapply(seq_len(nplots), function(x) plot_ly()) } s1 <- subplot(plotList(6), nrows = 2,…
Matt Dnv
  • 1,620
  • 13
  • 23
14
votes
1 answer

How to set different text and hoverinfo text

I am working with the plotly package, and I cannot find a way to display different things on the chart itself and in the hoverinfo. Here is an example of a barchart: library(plotly) library(dplyr) data(iris) df <- iris %>% group_by(Species) %>% …
Arlaf
  • 309
  • 1
  • 4
  • 8
14
votes
2 answers

Add Regression Plane to 3d Scatter Plot in Plotly

I am looking to take advantage of the awesome features in Plotly but I am having a hard time figuring out how to add a regression plane to a 3d scatter plot. Here is an example of how to get started with the 3d plot, does anyone know how to take it…
Josh
  • 1,800
  • 3
  • 15
  • 21
12
votes
4 answers

custom colors in R Plotly

I'm currently a beginner in Plotly and have a problem I can't seem to solve. I have my plotly stacked bar chart but I don't know how to color each individual category. I am currently using R. This is my current stacked bar chart: My current code…
DLo
  • 221
  • 1
  • 3
  • 7
11
votes
1 answer

R plotly hover label text alignment

I'm adding custom hover text for scatterplot points in a plotly graph in R. It appears to be aligning the text left, center, or right depending on whether the text box is shown to the right, center, or the left of the plot points, respectively. I'd…
Brian Stamper
  • 2,143
  • 1
  • 18
  • 41
1
2 3
80 81