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

issue 324 #325

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/plot_topoplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,20 @@ function plot_topoplot!(
)
end

clims = @lift (min($data...), max($data...))
# Set the color limits (`clims`) either from the config if specified by user or dynamically based on the data.
if haskey(config.visual, :limits)
clims = Observable(config.visual.limits)
else
clims = @lift (min($data...), max($data...))
end

if clims[][1] ≈ clims[][2]
@warn """The min and max of the value represented by the color are the same, it seems that the data values are identical.
We disable the color bar in this figure.
Note: The identical min and max may cause an interpolation error when plotting the topoplot."""
config_kwargs!(config, layout = (; use_colorbar = false))
else

vladdez marked this conversation as resolved.
Show resolved Hide resolved
ticks = @lift LinRange($clims[1], $clims[2], 5)
rounded_ticks = @lift string.(round.($ticks, digits = 2)) # Round to 2 decimal places
@lift config_kwargs!(
Expand Down
11 changes: 11 additions & 0 deletions test/test_topoplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,14 @@ end
colgap!(f.layout, 0)
f
end

@testset "topoplot: shared colorbars" begin
data_1, positions = TopoPlots.example_data()
data_2 = data_1 .* 100
min, max = minimum(data_2[:,5,1]), maximum(data_2[:,5,1])

f = Figure()
plot_topoplot!(f[1,1], data_1[:,5,1], positions=positions, visual=(; limits=(min,max)), layout = (; use_colorbar = false)) # how to increase the gap?
plot_topoplot!(f[1,2], data_2[:,5,1], positions=positions, visual=(; limits=(min,max)))
f
vladdez marked this conversation as resolved.
Show resolved Hide resolved
end
Loading