Scaling viz plots in GeoStats

For no particular reason, I wanted to keep the geometry data without transformation. Here, for the record, is what I did:

First, I found the boundingbox for each met area and find the min and max x, y values

function bbminmax(gt)
    bb = boundingbox(gt.geometry)
    minx, miny = coordinates(bb.min)[1:2]
    maxx, maxy = coordinates(bb.max)[1:2]
    return (minx, miny, maxx, maxy)
end

I could then find the biggest x-axis range and, separately, the biggest y-axis range of any of the met areas and position these symmetrically around the mean x, y for each map (I used a dataframe row for these parameters for each met area). I allowed 5% whitespace around the biggest dimension:

        for met in eachrow(df)
            met.minx, met.miny, met.maxx, met.maxy = bbminmax(gt |> Filter(row -> !ismissing(row.newLocalAuthority) && row.newLocalAuthority in met.boroughs))
        end
        df.xrange = df.maxx - df.minx
        df.yrange = df.maxy - df.miny
        xaxisrange = maximum(df.xrange) * 1.05
        yaxisrange = maximum(df.yrange) * 1.05
        df.xaxismin .= (df.minx .+ df.maxx .- xaxisrange) ./ 2.0
        df.xaxismax .= (df.minx .+ df.maxx .+ xaxisrange) ./ 2.0
        df.yaxismin .= (df.miny .+ df.maxy .- yaxisrange) ./ 2.0
        df.yaxismax .= (df.miny .+ df.maxy .+ yaxisrange) ./ 2.0

Then, in the viz! I was able to use axis limits for each plot:

function citymap(gt, df)
    fig = Mke.Figure()
    ax = []
    for (i, met) in enumerate(eachrow(df))
        longt = gt |> Filter(row -> !ismissing(row.newLocalAuthority) && row.newLocalAuthority in met.boroughs)
        col = log10.(longt.rat) # Can't currently have consistent colour scale across different plots
        push!(ax, Mke.Axis(fig[div(i - 1, 2)+1, mod(i - 1, 2)+1], title=met.metname, titlesize=10.0f0, limits=(met.xaxismin, met.xaxismax, met.yaxismin, met.yaxismax),
                    xlabel="BNG Easting",  xlabelsize=8.0f0, xtickformat="{:.0f}", xticklabelsize=6.0f0,
                    ylabel="BNG Northing", ylabelsize=8.0f0, ytickformat="{:.0f}", yticklabelsize=6.0f0))
        viz!(ax[i], longt.geometry, color=col, colorscheme=:hawaii, colorrange=extrema(col), facetcolor="black", showfacets=true)
        ax[i].aspect = Mke.DataAspect()
    end
    Mke.Colorbar(fig[1:2, 3], limits=extrema(gt.rat), colormap="hawaii", scale=log10, tickformat="{:.1f}", ticklabelsize=8.0f0,
            label="Multiple of national average funding per capita", labelsize=10.0f0)
    #    This common colorbar is not consistent with charts!
    Mke.display(fig)
end

This produces this set of maps:

This is great, and almost perfect!
Major: The colour scale is not consistent between maps. The colours in each map are dependent on the map data. The single colour bar is therefore a lie! (but this is my lie, not GeoStat’s)
Minor: I’d like to be able to have slightly thinner boundary lines. I can change the colour but not the weight of these lines, I think.

1 Like