Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow colorrange as an attribute for Colorbar, which is consistent with plot types #1066

Merged
merged 2 commits into from Jul 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/makielayout/defaultattributes.jl
Expand Up @@ -353,7 +353,9 @@ function default_attributes(::Type{Colorbar}, scene)
"The colormap that the colorbar uses."
colormap = lift_parent_attribute(scene, :colormap, :viridis)
"The range of values depicted in the colorbar."
limits = (0f0, 1f0)
limits = nothing
"The range of values depicted in the colorbar."
colorrange = nothing
"The align mode of the colorbar in its parent GridLayout."
alignmode = Inside()
"The number of steps in the heatmap underlying the colorbar gradient."
Expand Down Expand Up @@ -855,7 +857,7 @@ function attributenames(::Type{LegendEntry})
(:label, :labelsize, :labelfont, :labelcolor, :labelhalign, :labelvalign,
:patchsize, :patchstrokecolor, :patchstrokewidth, :patchcolor,
:linepoints, :linewidth, :linecolor, :linestyle,
:markerpoints, :markersize, :markerstrokewidth, :markercolor, :markerstrokecolor,
:markerpoints, :markersize, :markerstrokewidth, :markercolor, :markerstrokecolor,
:polypoints, :polystrokewidth, :polycolor, :polystrokecolor)
end

Expand Down
17 changes: 16 additions & 1 deletion src/makielayout/layoutables/colorbar.jl
Expand Up @@ -70,11 +70,26 @@ function layoutable(::Type{<:Colorbar}, fig_or_scene; bbox = nothing, kwargs...)
ticklabelsvisible, ticks, tickformat, ticksize, ticksvisible, ticklabelpad, tickalign,
tickwidth, tickcolor, spinewidth, topspinevisible,
rightspinevisible, leftspinevisible, bottomspinevisible, topspinecolor,
leftspinecolor, rightspinecolor, bottomspinecolor, colormap, limits,
leftspinecolor, rightspinecolor, bottomspinecolor, colormap, limits, colorrange,
halign, valign, vertical, flipaxis, ticklabelalign, flip_vertical_label,
nsteps, highclip, lowclip,
minorticksvisible, minortickalign, minorticksize, minortickwidth, minortickcolor, minorticks, scale)

limits = lift(limits, colorrange) do limits, colorrange
if isnothing(limits)
if isnothing(colorrange)
return (0, 1)
else
return colorrange
end
else
if !isnothing(colorrange)
error("Both colorrange + limits are set, please only set one, they're aliases. colorrange: $(colorrange), limits: $(limits)")
end
return limits
end
end

SimonDanisch marked this conversation as resolved.
Show resolved Hide resolved
decorations = Dict{Symbol, Any}()

protrusions = Node(GridLayoutBase.RectSides{Float32}(0, 0, 0, 0))
Expand Down