Home > Back-end >  plotly line chart with zero logarithmic scale
plotly line chart with zero logarithmic scale

Time:12-23

does anyone know how to deal with line charts in log scale where there are zero values in plotly? The lines sort of just disappear.

library(tidyverse)
library(lubridate)
library(plotly)

df2 <- tibble::tribble(
  ~SAMPLE_DATE, ~REPORT_RESULT_VALUE,
  "2018-10-04",                 0.05,
  "2019-05-05",                 0.01,
  "2019-10-04",                    0,
  "2020-06-05",                 0.01,
  "2020-09-11",                    0,
  "2021-04-23",                    0,
  "2022-05-08",                 0.06 ) %>% 
  mutate(SAMPLE_DATE = ymd(SAMPLE_DATE))


plot_ly(data = df2) %>%
  add_trace(x = ~SAMPLE_DATE,
            y = ~REPORT_RESULT_VALUE,
            mode = "lines markers") %>%
  layout(xaxis = list(title = 'Sample date'),
         yaxis = list(title = "Concentration (mg/L)",
                      type = "log"))

enter image description here

I found a similar post in the plotly forum a while ago, but no solution: enter image description here )

  • Related