How to create x-axis breaks in a CDF in R? -
using following data, total number of seconds:
$head date-subtraction_total_seconds.csv 15806856.0 15806970.0 190922.0 860863.0 33441.0 15806835.0 84041.0 17197453.0 17195029.0 -48.0
i pull data r:
df<-read.delim("date-subtraction.csv",sep=",",header=f) df<-data.frame(seconds=df$v1,days=df$v1/86400)
i create cdf:
ggplot(df, aes(x=df$days, y=ecdf(df$days)(df$days)))+ geom_step(size=2.2,color="red")+geom_step(color="cyan",size=1.5)+ scale_y_continuous(labels = percent_format(), limits=c(0,1))+ labs(x="time (days)", y="% total")+ ggtitle("cumulative distritubtion function")+ xlim(-1,8)
when try make x-axis labels break @ specific points, receive odd message adding scale, graph changes , lables seem stack on top of each other:
ggplot(df, aes(x=df$days, y=ecdf(df$days)(df$days)))+ geom_step(size=2.2,color="red")+geom_step(color="cyan",size=1.5)+ scale_y_continuous(labels = percent_format(), limits=c(0,1))+ labs(x="time (days)", y="% total")+ ggtitle("cumulative distritubtion function")+ xlim(-1,8)+ scale_x_discrete(breaks = c(0,1,2,3,4,6,7)) "scale 'x' present. adding scale 'x', replace existing scale."
do need create days factor? there way create these breaks?
you adding scale x axis xlim()
, scale_x_discrete()
. instead, should use limits argument withing scale_x_discrete()
:
ggplot(df, aes(x=df$days, y=ecdf(df$days)(compliancedatediff$days)))+ geom_step(size=2.2,color="red")+geom_step(color="cyan",size=1.5)+ scale_y_continuous(labels = percent_format(), limits=c(0,1))+ labs(x="time (days)", y="% total")+ ggtitle("cumulative distritubtion function")+ scale_x_discrete(breaks = c(0,1,2,3,4,6,7), limits = c(-1, 8)
Comments
Post a Comment