I want to make a triangle plot represents the response surface for all possible combinations of X
, Y
and Z
factors and the gradient area inside the triangle expresses the response variable Gi
. The dots represent the ten combinations of X
, Y
and Z
in data frame dt
. The correlation between Gi
and (X
, Y
, Z
) is defined as mdl <- lm (Gi ~ X*Y*Z)
. Here is the data and what I have tried:
X <- rep(c(.45,.4,.55,.4,.43,.5,.43,.5,.43,.48), each = 3)
Y <- rep(c(.15, .12,.22,.14,.14,.19,.12, .17,.17,.12 ), each = 3)
Z <- rep(c(.15,.22,.12,.12,.19,.14,.14,.17,.12,.17), each = 3)
Gi <- c(353,381,320,312,335,265,394,350,374,320,299,316,300,304,295,360,331,395,351,280,342,299,303,279,374,364,419,306,290,315)
dt <- data.frame (X, Y, Z, Gi)
ggtern(data = dt, aes(x = X, y = Y, z = Z, value = Gi)) +
stat_interpolate_tern(geom="polygon",
formula = value ~ x+y,
method = lm,
aes(fill = ..level..), expand = 1) +
scale_fill_gradient(low="green", high="blue") +
geom_point (fill = "white", size = 3, shape = 21, color = "white") +
theme_gray () +
theme ( tern.axis.arrow.show = T)
However, the output is not what I am looking for. I found an exciting example of a ternary plot heatmap using Python, which is like what I want. However, I am only familiar with R, and I'd like to make something similar. How could I do this in R?
Please find the link for the Python code that inspired me.