contourf
contourf(xs, ys, zs; kwargs...)
Plots a filled contour of the height information in zs
at horizontal grid positions xs
and vertical grid positions ys
.
The attribute levels
can be either
an
Int
that produces n equally wide levels or bandsan
AbstractVector{<:Real}
that lists n consecutive edges from low to high, which result in n-1 levels or bands
You can also set the mode
attribute to :relative
. In this mode you specify edges by the fraction between minimum and maximum value of zs
. This can be used for example to draw bands for the upper 90% while excluding the lower 10% with levels = 0.1:0.1:1.0, mode = :relative
.
In :normal mode, if you want to show a band from -Inf
to the low edge, set extendlow
to :auto
for the same color as the first level, or specify a different color (default nothing
means no extended band) If you want to show a band from the high edge to Inf
, set extendhigh
to :auto
for the same color as the last level, or specify a different color (default nothing
means no extended band).
If levels
is an Int
, the contour plot will be rectangular as all zs
will be covered. This is why Axis
defaults to tight limits for such contourf plots. If you specify levels
as an AbstractVector{<:Real}
, however, note that the axis limits include the default margins because the contourf plot can have an irregular shape. You can use tightlimits!(ax)
to tighten the limits similar to the Int
behavior.
Attributes
Available attributes and their defaults for Plot{Makie.contourf}
are:
colormap :viridis
colorscale identity
extendhigh "nothing"
extendlow "nothing"
inspectable true
levels 10
mode :normal
nan_color :transparent
transparency false
using CairoMakie
using DelimitedFiles
volcano = readdlm(Makie.assetpath("volcano.csv"), ',', Float64)
f = Figure()
Axis(f[1, 1])
co = contourf!(volcano, levels = 10)
Colorbar(f[1, 2], co)
f
using CairoMakie
using DelimitedFiles
volcano = readdlm(Makie.assetpath("volcano.csv"), ',', Float64)
f = Figure()
ax = Axis(f[1, 1])
co = contourf!(volcano,
levels = range(100, 180, length = 10),
extendlow = :cyan, extendhigh = :magenta)
tightlimits!(ax)
Colorbar(f[1, 2], co)
f
using CairoMakie
using DelimitedFiles
volcano = readdlm(Makie.assetpath("volcano.csv"), ',', Float64)
f = Figure()
ax = Axis(f[1, 1])
co = contourf!(volcano,
levels = range(100, 180, length = 10),
extendlow = :auto, extendhigh = :auto)
tightlimits!(ax)
Colorbar(f[1, 2], co)
f
Relative mode
Sometimes it's beneficial to drop one part of the range of values, usually towards the outer boundary. Rather than specifying the levels to include manually, you can set the mode
attribute to :relative
and specify the levels from 0 to 1, relative to the current minimum and maximum value.
using CairoMakie
using DelimitedFiles
volcano = readdlm(Makie.assetpath("volcano.csv"), ',', Float64)
f = Figure(size = (800, 400))
Axis(f[1, 1], title = "Relative mode, drop lowest 30%")
contourf!(volcano, levels = 0.3:0.1:1, mode = :relative)
Axis(f[1, 2], title = "Normal mode")
contourf!(volcano, levels = 10)
f
These docs were autogenerated using Makie: v0.20.10, GLMakie: v0.9.11, CairoMakie: v0.11.12, WGLMakie: v0.9.10