choropleth(D, ids, vals; attrib="CODE", cmap="turbo", outline=true, kw...)
choropleth(D, att=""; attrib="", cmap="turbo", outline=true, kw...)
choropleth(D, data::GMTdataset, att=""; attrib="", cmap="turbo", outline=true, kw...)
choropleth(D, data::Dict; outline=true, kw...)
choropleth(D, data::NamedTuple; outline=true, kw...)
choropleth(D, vals::Vector{<:Real}; attrib="CODE", outline=true, kw...)
Create a choropleth map visualization from geographic data with color-coded regions.
Arguments
D: Geographic data - either a file path (String) or Vector{GMTdataset} containing polygons.
ids::Vector{<:AbstractString}: Region identifiers to match with the attribute values.
vals::Vector{<:Real}: Numeric values to map to colors for each region.
att: Attribute column name (positional argument) for coloring when values are in the dataset.
data::GMTdataset: Dataset containing attributes to join with geographic features (must have text column).
data::Dict: Dictionary mapping region identifiers to values.
data::NamedTuple: Named tuple with region identifiers as keys and values.
Keywords
attrib: Attribute name to match identifiers (default: “CODE”). Takes precedence over positional att.
cmap: A colormap name (default: “turbo”) or a GMTcpt colormap.
outline: Draw polygon outlines. true (default), false, or a pen specification string.
kw...: Additional arguments passed to the plotting function (e.g., proj, region, title).
Returns
Methods
- With IDs and values:
choropleth(D, ids, vals) - Explicit region IDs and corresponding values.
- From attribute:
choropleth(D, att) - Extract values from a numeric attribute column in D.
- With GMTdataset:
choropleth(D, data, att) - Join D with data using text column for matching.
- With Dict:
choropleth(D, Dict("PT"=>10, "ES"=>20)) - Map from region codes to values.
- With NamedTuple:
choropleth(D, (PT=10, ES=20)) - Same as Dict but with named tuple syntax.
- Values only:
choropleth(D, vals) - Values in order of unique IDs extracted from D.
Examples
Using explicit IDs and values
D = getdcw("PT,ES,FR", file=:ODS)
choropleth(D, ["PT","ES","FR"], [10.0, 20.0, 30.0])
Using a Dict
choropleth(D, Dict("PT"=>10, "ES"=>20, "FR"=>30))
With custom colormap and no outlines
choropleth(D, ["PT","ES","FR"], [1.0, 2.0, 3.0], cmap="bamako", outline=false)
The example in “Tutorials”
D = getdcw("US", states=true, file=:ODS);
Df = filter(D, _region=(-125,-66,24,50), _unique=true);
pop = gmtread(TESTSDIR * "assets/uspop.csv");
choropleth(Df, pop, "NAME", proj=:guess, show=true)
UndefVarError: `getdcw` not defined
Stacktrace:
[1] top-level scope
@ In[2]:1
Source Code
This function has multiple methods:
choropleth(D::String, data::Dict; outline, kw...) - choropleth.jl:90
choropleth(D::String, data::GMTdataset; ...) - choropleth.jl:79
choropleth(D::String, data::GMTdataset, att::Union{AbstractString, Symbol}; attrib, cmap, outline, kw...) - choropleth.jl:79
choropleth(D::String, vals::Vector{<:Real}; attrib, outline, kw...) - choropleth.jl:102
choropleth(D::String, ids::Vector{<:AbstractString}, vals::Vector{<:Real}; attrib, cmap, outline, kw...) - choropleth.jl:59
choropleth(D::String, data::NamedTuple; outline, kw...) - choropleth.jl:98
choropleth(D::String; ...) - choropleth.jl:69
choropleth(D::String, att::Union{AbstractString, Symbol}; attrib, cmap, outline, kw...) - choropleth.jl:69
choropleth(D::Vector{<:GMTdataset}, vals::Vector{<:Real}; attrib, outline, kw...) - choropleth.jl:104
choropleth(D::Vector{<:GMTdataset}, data::NamedTuple; outline, kw...) - choropleth.jl:99
choropleth(D::Vector{<:GMTdataset}, data::Dict; outline, kw...) - choropleth.jl:91
choropleth(D::Vector{<:GMTdataset}, data::GMTdataset, att::Union{AbstractString, Symbol}; attrib, cmap, outline, kw...) - choropleth.jl:81
choropleth(D::Vector{<:GMTdataset}, data::GMTdataset; ...) - choropleth.jl:81
choropleth(D::Vector{<:GMTdataset}; ...) - choropleth.jl:71
choropleth(D::Vector{<:GMTdataset}, att::Union{AbstractString, Symbol}; attrib, cmap, outline, kw...) - choropleth.jl:71
choropleth(D, ids::Vector{<:AbstractString}, vals::Vector{<:Real}; attrib, cmap, outline, kw...) - choropleth.jl:61