This is some snippets of How to draw a ggplot curve over a mixture gaussian model
ggplot(mix_example) + geom_histogram(aes(x = x, y = ..density..)) +
stat_function(geom = "line", fun = fun_prop, color="red",
args = list(mean = comp_1[1], sd = comp_1[2],
proportion = proportions[1])) +
stat_function(geom = "line", fun = fun_prop, color="green",
args = list(mean = comp_2[1], sd = comp_2[2],
proportion = proportions[2]))+
stat_function(geom = "line", fun = fun_prop, color="blue",
args = list(mean = comp_3[1], sd = comp_3[2],
proportion = proportions[3]))
The Snippets above add 3 stat function to draw a cluster line over a density of mixture distribution, the argument (args) come from flexmix model which consist mean and standard deviation for each cluster of mixture distribution, I would like to expand this to an "n degree" so that it applies to plot an n lines of n clusters of mixture distribution. But I wonder is there any approach to do it without adding stat_function one by one