I am struggling with geom_smooth on creating a geometrical smoothing line. Below I report the code:
library(ggplot2)
#DATAFRAME
RawData <- data.frame("Time" = c(0, 4, 8, 24, 28, 32, 0, 4, 8, 24, 28, 32), "Curing" = c(0, 28.57, 56.19, 86.67, 89.52, 91.42, 0, 85.71, 93.33, 94.28, 97.62, 98.09), "Grade" = c("Product A", "Product A", "Product A", "Product A", "Product A", "Product A", "Product B", "Product B", "Product B", "Product B", "Product B", "Product B"))
attach(RawData)
#GRAPH
Graph <- ggplot(data=RawData, aes(x=`Time`, y=`Curing`, col=Grade)) + geom_point(aes(color = Grade), shape = 1, size = 2.5) + geom_smooth(level=0.50, span = 0.9999999999) + scale_color_manual(values=c('#f92410','#644196')) + xlab("Tempo espresso in ore") + ylab("% Di reticolazione") + labs(color='') + theme(legend.justification = "top")
Graph + geom_rug(aes(color = Grade))
Obtaining this plot (sorry for my overlying writings):
I get a graph which is nice for the red line, but with an unacceptable hump on the blue one.I would like to have a fitting curve similar to the one I draw on pale blue.
My idea was to make a geom_smooth
with logarithmic function, but I am not able to do it and browsing in stackoverflow
I was not able to find a solution. Does somebody know how I can do? I mean either:
- add a logarithmic smoothing with function, maybe
y~ a + b*log(x)
which should work; - any other way to have the smoothing line going across the data point;