Plotting with ggplot2: “Error: Discrete value supplied to continuous scale” on categorical y-axis

后端 未结 3 611
一生所求
一生所求 2020-11-29 04:26

The plotting code below gives Error: Discrete value supplied to continuous scale

What\'s wrong with this code? It works fine until I try to change the s

3条回答
  •  無奈伤痛
    2020-11-29 04:55

    In my case, you need to convert the column(you think this column is numeric, but actually not) to numeric

    geom_segment(data=tmpp, 
       aes(x=start_pos, 
       y=lib.complexity, 
       xend=end_pos, 
       yend=lib.complexity)
    )
    # to 
    geom_segment(data=tmpp, 
       aes(x=as.numeric(start_pos), 
       y=as.numeric(lib.complexity), 
       xend=as.numeric(end_pos), 
       yend=as.numeric(lib.complexity))
    )
    

提交回复
热议问题