I would like to plot of a (x,y) → Bool function as a contour plot. For the function I am plotting I get a lot of ghosting. The closer to 45° the line is the better it looks. Compare the heatmap to the contour plots:
Do you have any tips on how I can get the contour plotting done reliably? Is there a better way to plot contours and boundaries? Ideally, I’d like to get a nice vector plots with lines on the boundaries.
@owiecc, the following workflow with a grain of ImageFiltering seems to be more robust, not requiring negating the boolean function, nor tuning the contour level between 0 and 1:
using Plots; gr()
boolxy(x,y) = (y>0.6-1e-3*x) & (y>5e-4*x-0.1) & (y>0.2) ? true : false
x, y = LinRange(0,900,1000), LinRange(0,0.5,1000)
z = [boolxy(x,y) for y in y, x in x]
using ImageFiltering
kern1 = centered([1/3, 1/3, 1/3])
kernf = kernelfactors((kern1, kern1))
w = imfilter(z, kernf)
plot(heatmap(x,y,w), contour(x,y,w,levels=[0.5]), colorbar=false,dpi=300)
Unfortunately the function comes from some funky transformations so I don’t know the boundary equations. But I like the solution with the blur filter. I guess it makes it easier for the contour algorithm to trace the edges if the function is a bit smoother.