Engee 文档

n.海克宾

该页面正在翻译中。

hexbin(xs, ys; kwargs...)

为观测绘制具有六边形箱的热图 xys.

地块类型

绘图类型别名 n.海克宾 功能是 N.海克宾.

例子:

设置垃圾箱数量

设置 垃圾箱 对于一个整数,将x和y的桶数设置为该值。一个维度的最小桶数为2。 </无翻译>

using CairoMakie
using Random
Random.seed!(1234)

f = Figure(size = (800, 800))

x = rand(300)
y = rand(300)

for i in 2:5
    ax = Axis(f[fldmod1(i-1, 2)...], title = "bins = $i", aspect = DataAspect())
    hexbin!(ax, x, y, bins = i)
    wireframe!(ax, Rect2f(Point2f.(x, y)), color = :red)
    scatter!(ax, x, y, color = :red, markersize = 5)
end

f
cb984ea

你也可以传递一个整数元组来分别控制x和y。 </无翻译>

using CairoMakie
using Random
Random.seed!(1234)

f = Figure(size = (800, 800))

x = rand(300)
y = rand(300)

for i in 2:5
    ax = Axis(f[fldmod1(i-1, 2)...], title = "bins = (3, $i)", aspect = DataAspect())
    hexbin!(ax, x, y, bins = (3, i))
    wireframe!(ax, Rect2f(Point2f.(x, y)), color = :red)
    scatter!(ax, x, y, color = :red, markersize = 5)
end

f
1b47f47

设置单元格的大小

您也可以通过设置直接控制单元格大小 细胞大小 关键字。 在这种情况下, 垃圾箱 置被忽略。

六边形的高度大于其宽度。 这就是为什么为x和y设置相同的大小会导致不均匀的六边形。 </无翻译>

using CairoMakie
using Random
Random.seed!(1234)

f = Figure(size = (800, 800))

x = rand(300)
y = rand(300)

for (i, cellsize) in enumerate([0.1, 0.15, 0.2, 0.25])
    ax = Axis(f[fldmod1(i, 2)...], title = "cellsize = ($cellsize, $cellsize)", aspect = DataAspect())
    hexbin!(ax, x, y, cellsize = (cellsize, cellsize))
    wireframe!(ax, Rect2f(Point2f.(x, y)), color = :red)
    scatter!(ax, x, y, color = :red, markersize = 5)
end

f
79dafaf

要获得均匀大小的六边形,请将单元格大小设置为单个数字。 这个数字定义了单元格的宽度,高度将计算为 2*step_x/sqrt(3). 请注意,六边形的视觉外观只有在x和y轴具有相同的缩放比例时才会出现,这就是为什么我们使用 方面=DataAspect() 在这些例子中。 </无翻译>

using CairoMakie
using Random
Random.seed!(1234)

f = Figure(size = (800, 800))

x = rand(300)
y = rand(300)

for (i, cellsize) in enumerate([0.1, 0.15, 0.2, 0.25])
    ax = Axis(f[fldmod1(i, 2)...], title = "cellsize = $cellsize", aspect = DataAspect())
    hexbin!(ax, x, y, cellsize = cellsize)
    wireframe!(ax, Rect2f(Point2f.(x, y)), color = :red)
    scatter!(ax, x, y, color = :red, markersize = 5)
end

f
89c6797

隐藏低计数的六边形

计数低于的所有六边形 门槛 将被移除: </无翻译>

using CairoMakie
using Random
Random.seed!(1234)

f = Figure(size = (800, 800))

x = randn(100000)
y = randn(100000)

for (i, threshold) in enumerate([1, 10, 100, 500])
    ax = Axis(f[fldmod1(i, 2)...], title = "threshold = $threshold", aspect = DataAspect())
    hexbin!(ax, x, y, cellsize = 0.4, threshold = threshold)
end
f
7f8380e

更改仓中观测值数的比例

您可以将缩放函数传递给 色阶;色阶 关键字,在绘制之前将应用于bin计数。 </无翻译>

using CairoMakie
using Random
Random.seed!(1234)

x = randn(100000)
y = randn(100000)

f = Figure()
hexbin(f[1, 1], x, y, bins = 40,
    axis = (aspect = DataAspect(), title = "colorscale = identity"))
hexbin(f[1, 2], x, y, bins = 40, colorscale=log10,
    axis = (aspect = DataAspect(), title = "colorscale = log10"))
f
bec0056

显示零计数六边形

通过设置 阈值=0,将显示符合输入数据限制的所有六边形。 在这个例子中,我们在颜色表的开头添加一个透明的颜色,并勾画每个六边形,这样空的六边形是可见的,但不会太分散注意力。 </无翻译>

using CairoMakie
using DelimitedFiles


a = map(Point2f, eachrow(readdlm(assetpath("airportlocations.csv"))))

f, ax, hb = hexbin(a,
    cellsize = 6,
    axis = (; aspect = DataAspect()),
    threshold = 0,
    colormap = [Makie.to_color(:transparent); Makie.to_colormap(:viridis)],
    strokewidth = 0.5,
    strokecolor = :gray50,
    colorscale = Makie.pseudolog10)

tightlimits!(ax)

Colorbar(f[1, 2], hb,
    label = "Number of airports",
    height = Relative(0.5)
)
f
bd193de

对观测值应用权重

</无翻译>

using CairoMakie

using Random
Random.seed!(1234)

f = Figure(size = (800, 800))

x = 1:100
y = 1:100
points = vec(Point2f.(x, y'))

weights = [nothing, rand(length(points)), Makie.StatsBase.eweights(length(points), 0.005), Makie.StatsBase.weights(randn(length(points)))]
weight_labels = ["No weights", "Vector{<: Real}", "Exponential weights (StatsBase.eweights)", "StatesBase.weights(randn(...))"]

for (i, (weight, title)) in enumerate(zip(weights, weight_labels))
    ax = Axis(f[fldmod1(i, 2)...], title = title, aspect = DataAspect())
    hexbin!(ax, points; weights = weight)
    autolimits!(ax)
end

f
5e9e2dd

属性

阿尔法

默认值为 1.0

Colormap或color属性的alpha值。 多个阿尔法像在 图(alpha=0.2,颜色=(:红色,0.5),会成倍增加。

垃圾箱

默认值为 20

如果 Int型,设置x和y方向的箱数。 如果一个 N.婴儿{2, Int},分别设置x和y的箱数。

细胞大小

默认值为 什么都没有

如果一个 真实的,制作宽度相等的六边形 细胞大小. 如果一个 元组{Real, Real} 分别指定六边形宽度和高度。

颜色表

默认值为 @继承colormap:viridis

设置为数字采样的颜色表 颜色s. PlotUtils.cgrad(。..), 麦琪反向(any_colormap) 也可以使用,或者来自ColorBrewer或PlotUtils的任何符号。 要查看所有可用的颜色渐变,您可以调用 麦琪可用_gradients().

颜色变化

默认值为 自动的

表示的开始点和结束点的值 颜色表.

色阶;色阶

默认值为 身份认同

的颜色变换功能。 可以是任何函数,但只能与 颜色栏身份认同, 日志, 日志2, 日志10, sqrt,sqrt, 罗吉特, 麦琪伪科学10麦琪符号10.

海克利普

默认值为 自动的

Colorrange上方任何值的颜色。

低频,低频

默认值为 自动的

Colorrange以下任何值的颜色。

纳米色

默认值为 :透明

NaN值的颜色。

[医]斯特罗克色

默认值为 :黑色

没有可用的文档。

斯特罗克威德斯

默认值为 0

没有可用的文档。

门槛

默认值为 1

要显示的bin中的最少观测值。 如果为0,将显示符合数据限制的所有零计数六边形。

重量

默认值为 什么都没有

每个观测值的权重。 可以是 什么都没有 (每个观察值为1)或任何 [医]文摘{<: Real}StatsBase。抽象权重.