I am making a contour plot but can’t figure out how to interpolate the data so that a smooth contourplot forms. Is there a simple plotting function or way to interpolate the data?
library(ggplot2)
Treatments <- c('T1','T2','T3','T4','T5','T6','T7','T8','T9','T10','T11','T12')
Yield <- c(3.08,4.59,5.12,5.11,4.32,5.54,6.22,5.50,5.29,5.34,7.13,6.04)
Nweight <- c(0,0,0,0,60,60,60,60,120,120,120,120)
Pweight <- c(0,20,40,60,0,20,40,60,0,20,40,60)
NigerianData <- data.frame(Treatments,Nweight,Pweight,Yield)
ggplot() +
geom_contour_filled(data = NigerianData, mapping = aes(x = Nweight, y = Pweight, z = Yield)) +
scale_color_gradient(low = "blue", high = "red") +
labs(title = "Contourplot of Yield at different fertilizer concentrations",
x = "Nitrogen Rates",
y = "Phosphate Rates",
fill = "Yield")
I tried to plot using geom_contour_filled, expected a smooth contour plot but didn’t work.
New contributor
Karim Kahtaoui is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.