How does automatic level selection work for contourc function?
Show older comments
I'm trying to port an existing Matlab script to python. The code makes use of the contourc function, omitting the n argument to let Matlab decide how many contour levels to compute. I have found several python implementations for computing the contours, but they all rely on specifying a value for n or default to a constant value. Since the number of levels contourc computes are variable I'm having trouble producing consistent results between the two versions
The official documentation isn't too helpful here - only telling me the levels are chosen automatically.
C = contourc(Z) computes the contour matrix from data in matrix Z, where Z must be at least a 2-by-2 matrix. The contours are isolines in the units of Z. The number of contour lines and the corresponding values of the contour lines are chosen automatically.
Digging a little deeper I found this StackOverflow answer referring to an outdated pdf reference manual for Matlab R2012a. This documentation states:
The contouring algorithm first determines which contour levels to draw. If you specified the input vector v, the elements of v are the contour level values, and length(v) determines the number of contour levels generated. If you do not specify v, the algorithm chooses no more than 20 contour levels that are divisible by 2 or 5.
Getting closer, but still doesn't explain exactly how the levels are chosen. Can anyone tell me what criteria the algorithm uses to determine the number of contour levels?
Answers (0)
Categories
Find more on Contour Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!