Документация Engee

Colorbar

Страница в процессе перевода.

Для блока Colorbar требуются цветовая карта и кортеж нижних и верхних пределов. Ось цветовой карты будет проходить от нижнего до верхнего предела по визуальному представлению цветовой карты. Деления можно задавать аналогично Axis.

Вот как можно создать панели цветов вручную.

using CairoMakie

fig = Figure()

Axis(fig[1, 1])

# вертикальные панели цветов
Colorbar(fig[1, 2], limits = (0, 10), colormap = :viridis,
    flipaxis = false)
Colorbar(fig[1, 3], limits = (0, 5),
    colormap = cgrad(:Spectral, 5, categorical = true), size = 25)
Colorbar(fig[1, 4], limits = (-1, 1), colormap = :heat,
    highclip = :cyan, lowclip = :red, label = "Temperature")

# горизонтальные панели цветов
Colorbar(fig[2, 1], limits = (0, 10), colormap = :viridis,
    vertical = false)
Colorbar(fig[3, 1], limits = (0, 5), size = 25,
    colormap = cgrad(:Spectral, 5, categorical = true), vertical = false)
Colorbar(fig[4, 1], limits = (-1, 1), colormap = :heat,
    label = "Temperature", vertical = false, flipaxis = false,
    highclip = :cyan, lowclip = :red)

fig
e7d019e

При передаче plotobject, heatmap или contourf панель цветов будет автоматически настроена так, чтобы отслеживать соответствующие атрибуты этих объектов, такие как colormap, colorrange, highclip и lowclip. Чтобы впоследствии настроить эти атрибуты, измените их в объекте графика, иначе панель цветов и объект графика будут рассинхронизированы.

using CairoMakie

xs = LinRange(0, 20, 50)
ys = LinRange(0, 15, 50)
zs = [cos(x) * sin(y) for x in xs, y in ys]

fig = Figure()

ax, hm = heatmap(fig[1, 1][1, 1], xs, ys, zs)
Colorbar(fig[1, 1][1, 2], hm)

ax, hm = heatmap(fig[1, 2][1, 1], xs, ys, zs, colormap = :grays,
    colorrange = (-0.75, 0.75), highclip = :red, lowclip = :blue)
Colorbar(fig[1, 2][1, 2], hm)

ax, hm = contourf(fig[2, 1][1, 1], xs, ys, zs,
    levels = -1:0.25:1, colormap = :heat)
Colorbar(fig[2, 1][1, 2], hm, ticks = -1:0.25:1)

ax, hm = contourf(fig[2, 2][1, 1], xs, ys, zs,
    colormap = :Spectral, levels = [-1, -0.5, -0.25, 0, 0.25, 0.5, 1])
Colorbar(fig[2, 2][1, 2], hm, ticks = -1:0.25:1)

fig
28f918c

Экспериментальная категориальная поддержка

Warning Эта возможность может меняться вне критических выпусков, так как API еще не доработан.

Вы можете создать настоящую категориальную карту с удачно подобранными делениями по умолчанию, заключив цветовую карту в Makie.Categorical(cmap):

using CairoMakie
fig, ax, pl = barplot(1:3; color=1:3, colormap=Makie.Categorical(:viridis))
Colorbar(fig[1, 2], pl)
fig
ec46a9a

Здесь невозможно использовать cgrad(...; categorical=true), так как возникнет неоднозначная трактовка истинно категориальных значений.

Атрибуты

MarkdownAST.Heading(3)

Defaults to Inside()

The align mode of the colorbar in its parent GridLayout.

MarkdownAST.Heading(3)

Defaults to RGBf(0, 0, 0)

The color of the bottom spine.

MarkdownAST.Heading(3)

Defaults to true

Controls if the bottom spine is visible.

MarkdownAST.Heading(3)

Defaults to @inherit :colormap :viridis

The colormap that the colorbar uses.

MarkdownAST.Heading(3)

Defaults to nothing

The range of values depicted in the colorbar.

MarkdownAST.Heading(3)

Defaults to false

Flips the colorbar label if the axis is vertical.

MarkdownAST.Heading(3)

Defaults to true

Flips the axis to the right if vertical and to the top if horizontal.

MarkdownAST.Heading(3)

Defaults to :center

The horizontal alignment of the colorbar in its suggested bounding box.

MarkdownAST.Heading(3)

Defaults to Auto()

The height setting of the colorbar.

MarkdownAST.Heading(3)

Defaults to nothing

The color of the high clip triangle.

MarkdownAST.Heading(3)

Defaults to ""

The color bar label string.

MarkdownAST.Heading(3)

Defaults to @inherit :textcolor :black

The label color.

MarkdownAST.Heading(3)

Defaults to :regular

The label font family.

MarkdownAST.Heading(3)

Defaults to 5.0

The gap between the label and the ticks.

MarkdownAST.Heading(3)

Defaults to Makie.automatic

The label rotation in radians.

MarkdownAST.Heading(3)

Defaults to @inherit :fontsize 16.0f0

The label font size.

MarkdownAST.Heading(3)

Defaults to true

Controls if the label is visible.

MarkdownAST.Heading(3)

Defaults to RGBf(0, 0, 0)

The color of the left spine.

MarkdownAST.Heading(3)

Defaults to true

Controls if the left spine is visible.

MarkdownAST.Heading(3)

Defaults to nothing

The range of values depicted in the colorbar.

MarkdownAST.Heading(3)

Defaults to nothing

The color of the low clip triangle.

MarkdownAST.Heading(3)

Defaults to 0.0

The alignment of minor ticks on the axis spine

MarkdownAST.Heading(3)

Defaults to :black

The tick color of minor ticks

MarkdownAST.Heading(3)

Defaults to IntervalsBetween(5)

The tick locator for the minor ticks

MarkdownAST.Heading(3)

Defaults to 3.0

The tick size of minor ticks

MarkdownAST.Heading(3)

Defaults to false

Controls if minor ticks are visible

MarkdownAST.Heading(3)

Defaults to 1.0

The tick width of minor ticks

MarkdownAST.Heading(3)

Defaults to 100

The number of steps in the heatmap underlying the colorbar gradient.

MarkdownAST.Heading(3)

Defaults to RGBf(0, 0, 0)

The color of the right spine.

MarkdownAST.Heading(3)

Defaults to true

Controls if the right spine is visible.

MarkdownAST.Heading(3)

Defaults to identity

The axis scale

MarkdownAST.Heading(3)

Defaults to 12

The width or height of the colorbar, depending on if it’s vertical or horizontal, unless overridden by width / height

MarkdownAST.Heading(3)

Defaults to 1.0

The line width of the spines.

MarkdownAST.Heading(3)

Defaults to true

Controls if the parent layout can adjust to this element’s height

MarkdownAST.Heading(3)

Defaults to true

Controls if the parent layout can adjust to this element’s width

MarkdownAST.Heading(3)

Defaults to 0.0

The alignment of the tick marks relative to the axis spine (0 = out, 1 = in).

MarkdownAST.Heading(3)

Defaults to RGBf(0, 0, 0)

The color of the tick marks.

MarkdownAST.Heading(3)

Defaults to Makie.automatic

Format for ticks.

MarkdownAST.Heading(3)

Defaults to Makie.automatic

The horizontal and vertical alignment of the tick labels.

MarkdownAST.Heading(3)

Defaults to @inherit :textcolor :black

The color of the tick labels.

MarkdownAST.Heading(3)

Defaults to :regular

The font family of the tick labels.

MarkdownAST.Heading(3)

Defaults to 3.0

The gap between tick labels and tick marks.

MarkdownAST.Heading(3)

Defaults to 0.0

The rotation of the ticklabels.

MarkdownAST.Heading(3)

Defaults to @inherit :fontsize 16.0f0

The font size of the tick labels.

MarkdownAST.Heading(3)

Defaults to Makie.automatic

The space reserved for the tick labels. Can be set to Makie.automatic to automatically determine the space needed, :max_auto to only ever grow to fit the current ticklabels, or a specific value.

MarkdownAST.Heading(3)

Defaults to true

Controls if the tick labels are visible.

MarkdownAST.Heading(3)

Defaults to Makie.automatic

The ticks.

MarkdownAST.Heading(3)

Defaults to 5.0

The size of the tick marks.

MarkdownAST.Heading(3)

Defaults to true

Controls if the tick marks are visible.

MarkdownAST.Heading(3)

Defaults to 1.0

The line width of the tick marks.

MarkdownAST.Heading(3)

Defaults to RGBf(0, 0, 0)

The color of the top spine.

MarkdownAST.Heading(3)

Defaults to true

Controls if the top spine is visible.

MarkdownAST.Heading(3)

Defaults to :center

The vertical alignment of the colorbar in its suggested bounding box.

MarkdownAST.Heading(3)

Defaults to true

Controls if the colorbar is oriented vertically.

MarkdownAST.Heading(3)

Defaults to Auto()

The width setting of the colorbar. Use size to set width or height relative to colorbar orientation instead.