contourf
contour(x, y, Z)
Input: x, y, Z · Output: no output
What it is
Iso-lines through scalar field Z (a Mat with len(y) rows and len(x) columns) over axis vectors x, y (Vecs of numbers); contourf fills the bands between levels instead of only outlining them. All three arguments are always required — contour(Z) alone is a runtime error (contour(x, y, Z) needs three arguments), even though Z alone is enough information for some other libraries' contour calls. levels= (integer count, or a Vec of explicit level values) controls how many iso-lines are drawn or exactly which.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
contour(x, y, Z) | x scalar, Mat, vector, Vec, or numbernot documented yety scalar, Mat, vector, Vec, or numbernot documented yetZ scalar, Mat, vector, Vec, or numbernot documented yet | no output | levels= (integer count, or a Vec of explicit level values) controls how many iso-lines are drawn or exactly which. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
f = logspace(0, 3, 200)
mag = 1 ./ sqrt(1 + (f / 100) .^ 2)
semilogx(f, mag)
figure()
x = 1 to 50
semilogy(x, exp(0.1 * x))
figure()
loglog(f, mag)
figure()
samples = randn(500, seed = 2)
hist(samples, bins = 15)
figure()
g = meshgrid(-3 to 3 step 0.2, -3 to 3 step 0.2)
Z = sin(sqrt(g.x .^ 2 + g.y .^ 2))
contour(g.x, g.y, Z)
figure()
contourf(g.x, g.y, Z)
figure()
tbl = table(a = randn(30, seed = 3), b = randn(30, seed = 4), c = randn(30, seed = 5))
corr_heatmap(tbl)
figure()
corrplot(tbl)
· hist: figure 31 (500 points, 15 bins)
from plotting
How it works
contour(x, y, Z) / contourf(x, y, Z) -- iso-lines and filled bands over a scalar field. x and y are the axis vectors and Z is a matrix with y.len() rows and x.len() columns, matching what meshgrid implies and what matplotlib accepts. Passing the meshgrid matrices themselves works too: only their first row and first column carry new information, so they are reduced to axis vectors rather than rejected -- a script transcribed from Python passes contourf(KK, NN, Z) and should not have to be rewritten to say contourf(K, nuT, Z). NaN in Z masks a cell out, which is how a "the formula does not apply here" region is drawn (np.where(cond, v, np.nan) in the original).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.
See also
contour — documented in the same entry.