Search code examples
rggplot2line-plotggpubr

issues with continuous x axis using ggpubr::lineplot


I'm using ggpubr::lineplot to plot line plot. My x axis is continuous variable.

df <- data.frame(time=c(1, 5, 20),
                 len=c(4.2, 10, 29.5))
library(ggpubr)
ggline(df, x = "time", y = "len")

My time labels are equally spaced. It seems like lineplot treats time like factor instead of continuous variable.

Does anyone know how to correct that? I would like to use ggpubr::lineplot because it has many other functionalities. I know how to plot lines with just ggplot.


Solution

  • The numeric.x.axis argument is exactly for that!

    ggline(df, x = "time", y = "len", numeric.x.axis = TRUE)
    

    enter image description here