Using ggplot to reflect uneven spacing between time points

64 views Asked by At

I am plotting for longitudinal trjaectories, which are latent trajectories from the results of Growth Mixture modelling. My data were collected at uneven distributed time points, say age 13,15,17,21,24,27. I would like my graph to reflect that uneven spcaing, i.e., "stretched" for larger age gaps.

I have tried using scale_x_continuous, and ensured sweep (timepoints) is numeric. In the result plot, the labels were correct,but still had equal distance from each other.

age <- c(13,15,17,21,24,27)
p  <- ggplot(long_dta, aes(Sweep, value, group=numericID, colour=gmm2_grp)) 
+ geom_line() + geom_smooth(aes(group= gmm2_grp), method="loess", size=2, se=F)  
+ scale_y_continuous(limits = c(0,40)) 
+ scale_x_continuous(labels = age) 
+ labs(x="Age(years)",y="total_score",colour="Latent Class") 

the x-axis with my current code

As you can see, there's 1 "grid" between 3 and 5, 5 and 7, which are making perfect sense. But in that case, there should be 3 "grids" between 7, and 11, so on and so forth.

I would sincerely appreciate any suggestions on how I can reflect the uneven distribution of timepoints on my plot.

0

There are 0 answers