Ploty Bar chart issue - "Can't display both discrete and non-discrete data on same axis"

Hello !
I thought I had so much plotly experience gained in many hours of coding up shiny apps by now that I knew what I was doing,... but I'm stumped by this seemingly bizarre warning.

 Can't display both discrete and non-discrete data on same axis 

I still get a visually correct output, and warnings can be suppressed, but I'd like to understand the warning, and avoid raising it, in the first place.

I provide a simple reprex to duplicate my issue.
The warning triggers, when either

are called/executed on the console triggering the plot activity.

Can anyone shed some light on this ?
I don't know which axis its complaining about, the x or the y, in in either case, I have discrete factors on x, which I didnt think was ambigious. similarly y has integer 1,2,3 , so no crazy things going on here. not intentionally way.

please save my brain


smrypre <- tibble(
    y = c(1,2,3)

               levels = c("a","b","c"))

basep <- plot_ly(
    width = 600,
    height = 600,
    type = "bar"

p <- add_trace(basep, data=smry,name="tried with trace",x=~x, y=~y)

#Can't display both discrete & non-discrete data on same axis

p2 <- add_bars(basep, data=smry,name="tried with bars",x=~x, y=~y)

#Can't display both discrete & non-discrete data on same axis

Created on 2019-11-15 by the reprex package (v0.3.0)

Hi @nirgrahamuk. The warnings is not a big problem. It is because the x-axis of basep is defined as continuous if you didn't define anything. After that you plot the discrete values a, b and c on it, so the warnings come out. You can directly plot the bar chart.

plot_ly(data = smry, x = ~x, y = ~y, width = 600, height = 600)

Thank you !
This is the answer indeed. Default axis expectations of the basep I defined. Good catch :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.