plotly.R icon indicating copy to clipboard operation
plotly.R copied to clipboard

ggplotly doesn't show minor_breaks

Open kent37 opened this issue 7 years ago • 4 comments

ggplotly doesn't show lines created with minor_breaks:

library(ggplot2)
library(plotly)

x <- seq(0, 3.5, by = 0.5)
y <- x * 0.95
df <- data.frame(x, y)
gg <- ggplot(df, aes(x, y)) + geom_point() +
  scale_x_continuous(minor_breaks=seq(0, 3.5, 0.2))

gg # Vertical lines at intervals of 0.2
ggplotly(gg) # Vertical lines at even integers

image image

kent37 avatar Apr 18 '17 13:04 kent37

Might make sense to implement this when #878 happens

cpsievert avatar Apr 18 '17 14:04 cpsievert

I was wondering if there is any update regarding this issue, or if there is any workaround available in the meantime? Thanks!

VincentJ-EDF avatar Aug 06 '19 12:08 VincentJ-EDF

I solved the problem for vertical lines, but when I apply the same logic to horizontal lines, the plot is buggy. Meaning if you try to interact with the plot then it shifts, changes the display etc.

xtick <- seq(0, 3.5, 0.2)
xtick_text <- xtick
xtick_text[xtick_text %% 1 != 0] <- ""

# No Problem
layout(
  ggplotly(gg),
  xaxis = list(
    tickvals = xtick,
    ticktext = xtick_text)
)

verlinesggly

ytick <- seq(0, 3.5, 0.5)
ytick_text <- ytick
ytick_text[ytick_text %% 1 != 0] <- ""

# Somehow buggy
layout(
  ggplotly(gg),
  xaxis = list(
    tickvals = xtick,
    ticktext = xtick_text),
  yaxis = list(
    tickvals = ytick,
    ticktext = ytick_text)
)

horzlinesggply

Michi-Parz avatar Dec 04 '23 09:12 Michi-Parz

@Michi-Parz: thanks for this workaround, at least half of the problem is solved! It's a shame though that the actual bug still hasn't been resolved 7 years on...

Flocondeneige55 avatar Mar 01 '24 16:03 Flocondeneige55