Hello, I was creating a gantt plot for some made up data and I was noticing that the x-axis for my data not going off of 0, 0.5, 1, 1.5, 2, 2.5. Intead, the x-axis was going off of the discrete values that I provided. Is there any way to fix my data so that the lines for each patient is placed on a x-axis from 0->2.5 by 0.5 breaks? Thank you so much!
This is the code I am working with:
Gantt_Plot_Data_1<-tibble::tribble(
~Item, ~Patient, ~Drug.dose, ~'Start/End', ~Month,
1, 1, 4, "Start", 0.13,
2, 1, 4, "End", 0.55,
3, 1, 2, "Start", 0.65,
4, 1, 2, "End", 0.77,
5, 2, 10, "Start", 0.1,
6, 2, 10, "End", 0.17,
7, 2, 8, "Start", 0.2,
8, 2, 8, "End", 0.23,
9, 2, 2, "Start", 0.4,
10, 2, 2, "End", 0.67
)
head(Gantt_Plot_Data_1)
#> # A tibble: 6 x 5
#> Item Patient Drug.dose `Start/End` Month
#> <dbl> <dbl> <dbl> <chr> <dbl>
#> 1 1 1 4 Start 0.13
#> 2 2 1 4 End 0.55
#> 3 3 1 2 Start 0.65
#> 4 4 1 2 End 0.77
#> 5 5 2 10 Start 0.1
#> 6 6 2 10 End 0.17
library(ggplot2)
library(tidyverse)
Gantt_Plot_Data_1$Item<- as.integer(Gantt_Plot_Data_1$Item)
Gantt_Plot_Data_1$Patient<- as.factor(Gantt_Plot_Data_1$Patient)
Gantt_Plot_Data_1$Drug.dose<-as.factor(Gantt_Plot_Data_1$Drug.dose)
Gantt_Plot_Data_1$Month<-as.character(Gantt_Plot_Data_1$Month)
#Start/End is a character
ggplot(Gantt_Plot_Data_1, aes(Month, Patient, color=Drug.dose, group=Patient))+geom_line(size=10)+labs(x="Month from Surgery", y= "Patient", title = "Drug Dose")+ scale_x_discrete(breaks= seq(0,2.5, by=0.5),labels=c(0,0.5,1,1.5,2,2.5))