From this question I learned how to plot functions in a "deterministic form" (like y = a0x + a1x^2 + a2x^3 ...). I am wondering how to plot a function in a general form (like ax + by + c = 0)?
For some simple function in a general form, we can transform it to a "deterministic form", then convert the math function into a Julia function (like ax + by + c = 0 to y = (ax + c)/(-b)). However, for some complex function, it is not easy to write a Julia function.
Is there a way I can plot this function using Gadfly?
Mattriks suggests to use
Geom.contour
to plot functions in a general form in this issue.I have tried it in my example, and it works pretty good.
For example, in the function on the question:
Say the list of parameters is
para=[1.27274,0.625272,1.18109,-2.01996,-0.917423,-1.43166,0.124006,-0.365534,-0.357239,-0.175131,-1.45816,-0.0509896,-0.615555,-0.274707,-1.19282,-0.242188,-0.206006,-0.0447305,-0.277784,-0.295378,-0.456357,-1.0432,0.0277715,-0.292431,0.0155668,-0.327379,-0.143887,-0.924652]
In other words, a0 = 1.27274, a1 = 0.625272, etc.
Then we can use the following code to plot the graph.
To make
levels = [0.0]
work, we need to explicitly provide argumentsx, y, z
.