I'm looking to visualize some algebraic curves in Julia
I have the polynomials:
f1=(x^4+y^4-1)(x^2+y^2-2)+x^5y
f2 = x^2+2xy^2-2y^2-1/2
and I would like to plot V(f1) and V(f2) so I can see their common intersections. I have tried using contour plot in Gadfly.jl
but it seems to only allow me to plot one curve at a time. Is there a way to plot both curves in Gadfly.jl
or doing it in another Julia
package?
Gadfly is using a handy composite item: Layers
https://gadflyjl.org/stable/man/compositing/#Layers
These are freely accessible through the plot as plot_name.layers
and can be manually appended ( e.g. using append!(p.layers, new_layer)
). A personal favorite is building both layers prior to calling plot()
and implementing any necessary figure labels within the plot()
function:
using Gadfly
pol_one = layer(z=(x,y) -> (x^4 + y^4 - 1) * (x^2+y^2-2) + x^5 * y,
xmin=[-2], xmax=[2], ymin=[-2], ymax=[2],
Geom.contour(levels=[0;]))
pol_two = layer(z=(x,y) -> x^2 + 2x*y^2 - 2y^2 - 1/2,
xmin=[-2], xmax=[2], ymin=[-2], ymax=[2],
Geom.contour(levels=[0;]))
plot(p_layer, q_layer, Guide.xlabel("x"), Guide.ylabel("y"))