plotly.R
plotly.R copied to clipboard
ggplotly doesn't show minor_breaks
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
Might make sense to implement this when #878 happens
I was wondering if there is any update regarding this issue, or if there is any workaround available in the meantime? Thanks!
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)
)
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)
)
@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...