0

I am plotting my data using plot_ly and for some unknown reason it shows "doubling" lines connecting dots which should not be connected! i am getting a very different plot using ggplot... How to fix this with plotly?

My code:

test%>%ggplot(aes(
    year, value
   ))+geom_line()

plot_ly(test, x = ~year, y = ~value, type = 'scatter', mode = 'lines')

What I see:

plotly

enter image description here

ggplot

enter image description here

m45ha
  • 399
  • 1
  • 9
  • 1
    A guess: I wonder if plotly is treating it like geom_path, with data plotted in order of appearance instead of order of x axis. If so, could be fixed by arranging in order of X values in the step before plotting. – Jon Spring May 11 '23 at 04:28
  • 1
    I am not able to reproduce this given the current information. If you want great answers quickly, it's best to make your question reproducible. This includes sample data like the output from `dput()` or `reprex::reprex()` and any libraries you are using. Check it out: [making R reproducible questions](https://stackoverflow.com/q/5963269). – Kat May 12 '23 at 11:53

0 Answers0