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
6
votes
1 answer

Zoom on y-axis while using plotly::rangeslider

I would like to zoom in on the y-axis on a plotly plot that uses rangeslider. A reproducible example: library(ggplot2) library(plotly) p <- ggplot(faithful, aes(x = waiting)) + geom_histogram(bins = 30) p <- ggplotly(p) p <-…
NiklasvMoers
  • 309
  • 2
  • 13
6
votes
2 answers

First and last facets using facet_wrap with ggplotly are larger than middle facets

Using sample data: library(tidyverse) library(plotly) myplot <- diamonds %>% ggplot(aes(clarity, price)) + geom_boxplot() + facet_wrap(~ clarity, ncol = 8, scales = "free", strip.position = "bottom") + theme(axis.ticks.x = element_blank(), …
Nautica
  • 2,004
  • 1
  • 12
  • 35
6
votes
0 answers

Control legend behavior using Plotly's highlight feature with ggplotly

I've spent a good deal of time trying to figure out how to customize or control the legend behavior of Plotly when using Plotly's highlight() feature in combination with plotly::ggplotly(). Here is an example:…
fromtheloam
  • 435
  • 2
  • 12
6
votes
1 answer

How to make hyperlink in tooltip text reachable in ggplotly?

I would like to make a clickable hyperlink in a tooltip text in ggplotly. The hyperlink does seem to appear in the tooltip, but it can't be clicked. Before I can click, the tooltip dissappears. How can I make the tooltip appear long enough for me to…
rdatasculptor
  • 8,112
  • 14
  • 56
  • 81
6
votes
2 answers

ggplotly - only return tooltip hover text on certain geom objects

I have am plotting a bar graph geom with a point geom layered on top of that like so: plot_1 <- ggplot(results, aes(x=date, y = data, question_text=question_text, val1 = val1)) + geom_bar(stat = "identity", position = "dodge",…
Parseltongue
  • 11,157
  • 30
  • 95
  • 160
6
votes
1 answer

In plotly, how do I retain the information about both the lasso selection and the clicked point?

I'm using plotly::ggplotly() and I need the user to be able to both select a single point and to select multiple points with brushing. I want both selection options to exist in parallel. The user should be able to click on a point and to lasso…
DeanAttali
  • 25,268
  • 10
  • 92
  • 118
5
votes
3 answers

How to change legend position in ggplotly in R

The below code generates two plots using ggplot and ggplotly. Despite of using the layout() to ggplotly the legend is still at the right side. The legend is required to be at the bottom. Could anyone help to move the legend to bottom in the…
chas
  • 1,565
  • 5
  • 26
  • 54
5
votes
0 answers

Removing white spaces between facets when using ggplotly()

I wish to make a ggplot object interactive using plotly. When I use ggplotly(), huge white spaces are introduced between my facets, making the plot small and weird looking: Compared to how big and neat it looks when using ggplot only: My…
F.Mueni
  • 51
  • 4
5
votes
1 answer

Second y axis vanishing on ggplotly command with dynamick ticks =true, ggplot2

I have created the following dataframe and associated ggplot chart in R First we import the libraries using R library(plotly) library(ggplot2) Next we create the dataframe as follows dataframe_1<-data.frame("Month"=c(1:12)) …
Raghavan vmvs
  • 1,213
  • 1
  • 10
  • 29
5
votes
1 answer

X axis error with ggplotly and facet_wrap

I am trying to create a bar plots with ggplotly and facet_wrap. However, the x-axis looks weird for the second and third subplots. below is my code: library(plotly) library(ggplot2) library(dplyr) setInfo<-…
5
votes
1 answer

ggplot to ggplotly doesn't work with customized geom_boxplot width

When I try to set a customized width for my boxplot in ggplot, it works fine: p=ggplot(iris, aes(x = Species,y=Sepal.Length )) + geom_boxplot(width=0.1) But when I try to use ggplotly, the width (and the hjust) is default: p %>% ggplotly() What am…
Joelle
  • 63
  • 5
5
votes
1 answer

Formatting Shiny Plotly subplots - Individual titles and graph size

I'm trying to provide individual titles for each of my graphs within plotly's subplot function and I found a post where you can extend subplot using %>% layout(title = "Main Title) but I'd like individual titles for each graph (I'm using ggtitle but…
MayaGans
  • 1,815
  • 9
  • 30
5
votes
1 answer

Format tooltip in plotly for long text labels

Consider the simple example below. Is there a way to format the plotly tooltip such that the long text labels are visible in a box, rather than this absurd rectangle that cuts off values? library(ggplot2); library(plotly) df <- data.frame(x =…
Rich Pauloo
  • 7,734
  • 4
  • 37
  • 69
5
votes
1 answer

Add custom data label in ggplotly scatterplot

I would like to display the Species for each data point when the cursor is over the point rather than the than the x and y values. I use the iris dataset. Also I want to be able to click on a data point to make the label persistent and not get…
firmo23
  • 7,490
  • 2
  • 38
  • 114
5
votes
1 answer

Tooltip removes regression line ggplotly

I have the following code in server.R: library(shiny) library(plotly) art.data <- read.csv("data1.csv", stringsAsFactors = FALSE) shinyServer(function(input, output) { output$distPlot <- renderPlotly({ col.str <- paste0(input$colspa, ".",…
Charles
  • 63
  • 4
1 2
3
53 54