Questions tagged [ggplotly]

ggplotly is a function which converts a ggplot object into an interactive plotly object. It enables the usage of functions like zoom, hover, playing with the axis, appearing/disappearing group of points.

For more information and examples, please visit the website.

799 questions
2
votes
2 answers

How can I plot two lines from two columns of Data frame and scale the y axis using ggplot package

I am trying to compare the values of two columns of my data frame. I would like to use ggplot and plot two lines that indicates all values in first column are greater than the second column. Here is my df: C1 <-…
say.ff
  • 373
  • 1
  • 7
  • 21
2
votes
1 answer

R ggplot plotly mouseover tooltip not working. Error: undefined columns selected

I am trying to plot and use ggplotly for mouseover in geom_point objects. Here is my reproducible R script: require(ggplot2) library(ggrepel) library(plotly) # Create the data frame. sales_data <- data.frame( emp_name = rep(c("Sam", "Dave",…
Om Sao
  • 7,064
  • 2
  • 47
  • 61
2
votes
1 answer

ggplot2- Extending a geom_segment beyond visible range of plot

I am building a plot for a shiny app using ggplot and plotly. My data spans years, but the user is able to control the date range and just view a small amount at a time. I am trying to use geom_segments to represent durations of events(events with…
2
votes
1 answer

colored geom bar - plotly

How do you resolve the double labels when you hover over the filled geom_bar? This doesn't occur in the unfilled geom_bar # no fill library(plotly) dat <- data.frame( time = factor(c("Lunch","Dinner"), levels=c("Lunch","Dinner")), total_bill…
2
votes
1 answer

Heatmap - with diagonally split tiles

Could we use R to plot this figure?One grid cell with two values? Heatmaps showing the Kuiper distance values (upper-left triangles) and the (1-PSS) values (bottom-right triangles) Actually, this figure has two correlations coefficients, the top…
Hong
  • 49
  • 6
2
votes
2 answers

Map using ggplotly not showing correctly (R)

I have made a map using ggplot and plotted it using ggplotly. When it is in ggplot it looks like this: But when it is displayed using ggplotly, it looks like this: As you can kind of see, the individual regions are sort of splurging all over the…
Jaccar
  • 1,720
  • 17
  • 46
2
votes
1 answer

How to set decimal places at y-axis?

Im working on a Shinyapp, where i want to show some plots. I have one parameter, where at the y-axis R gives me values like 0.180000000008. Is there any posibility to set the limit of decimal places at 2? So it would be 0.18 I thought about using…
2
votes
1 answer

how can I stop ggploty() adding lines between map points?

I'm using plotly package to convert my ggmap into HTML. However, after I apply ggplotly(), there are lines produced between map points. My df looks like: df <- data.frame("Name" = c("A", "A", "A", "B","B"), "lat" = c(42.04614,…
Mr369
  • 384
  • 4
  • 17
2
votes
0 answers

plotly::ggplotly is breaking for certain facet-wrap data

I have a problem combining plotly::ggplotly (v4.7.1) with facet_wrap (v3.0.0) that I can't seem to generalise but is reproducible with a particular dataset (summary metrics for a set of tweets): require(tidyverse) require(plotly) d =…
geotheory
  • 22,624
  • 29
  • 119
  • 196
2
votes
1 answer

How to construct hover text without disabling geom_smooth?

The code library(ggplot2) library(plotly) df<-data.frame(replicate(2,sample(2000,size=29,replace=TRUE))) p <- ggplot(df, aes(x=X1, y=X2*1000,text=X1))+geom_point()+geom_smooth() p <- ggplotly(p, tooltip="text") print(p) produces the expected plot…
user3673
  • 665
  • 5
  • 21
2
votes
1 answer

Ggplotly with tooltip has problems using geom_rect()

I am trying to plot some data in a ggplotly plot. The x-axis contains dates. Ggplotly doesn't work well with dates as when I hover over a point, the date is displayed as a number. I solved this by setting a tooltip like below. Some sample data: x…
Stan
  • 480
  • 1
  • 5
  • 18
2
votes
0 answers

Add background section colors in plotly using shapes

I created a plot using ggplot where I added background colors at certain regions of the plot: p.ggplot + geom_rect(aes(xmin= -Inf, xmax= Inf, ymin= -5, ymax= 0.2),alpha=0.3, fill="#b71e3f") + geom_rect(aes(xmin= -Inf, xmax= Inf, ymin= 0.8, ymax=…
Carmen Sandoval
  • 2,266
  • 5
  • 30
  • 46
2
votes
1 answer

R Plotly stacked or filled bar chart show not correctly aligned bars

I do have the issue depicted below with filled or stacked bar charts using plotly. While the actual ggplot chart is perfectly aligned, I encounter the below issue in plotly. library(plotly) #> #> Attache Paket: 'plotly' #> The following object is…
Oliver
  • 441
  • 6
  • 14
2
votes
1 answer

Labels next to points in a plot using ggplotly() in R

I was wondering if there is a way to put labels next to points in a ggplotly() plot. If I use geom_text or geom_text_repel in ggplot(), the result is ok. But then if I call ggplotly(), I cannot see the labels I created anymore. For…
2
votes
1 answer

ggplotly on geom_bar and coord_flip seems to fail

I am able to plot a geom_bar as I want but when I try to wrap it with the ggplotly function it does not work. Anyone know a trick to make it work? library(ggplot2) library(plotly) # My df dataset a=runif(10, min = 0, max = 1) b=runif(10, min = -1,…
hans glick
  • 2,431
  • 4
  • 25
  • 40