Hello, if I run the code below with contourf and contour, I see two different times:
4.5 seconds and 1.5 seconds, respectively. Is this performance hit expected just filling in the contours?
plotting()
begin
using CairoMakie
using LaTeXStrings
using PlutoUI
end
function plotting()
x = range(-10,10,step=.01)
y = range(-10,10,step=.01)
@time z = circles(x,y)
@time fig, ax, cf =contour(x, y, z, colormap=:greens, fill=true)
ax.aspect = 1
return fig
end
function circles(x_vec, y_vec)
f(x,y) = x^2 + y^2
z = [f(x_i, y_i) for x_i in x_vec, y_i in y_vec]
return z
end
Yes contourf has to build polygons out of the contour lines that contour just plots as-is. And those polygons currently always get triangulated, even though CairoMakie doesn’t use the triangulation, only GLMakie needs it. I’m not sure which parts account for what percentage of the additional time, though. One could profile it
interesting, in that case it looks like it may be faster to heatmap, and then plot contours on top?
I guess that ask the question then of why ever use contourf? Perhaps for categorization and not continuous functions?