Skip to content

Commit

Permalink
switch from colorrange to limits in toposeries in colorbar
Browse files Browse the repository at this point in the history
vladdez committed Jan 14, 2025
1 parent d38bd5d commit 981fa63
Showing 4 changed files with 23 additions and 47 deletions.
8 changes: 2 additions & 6 deletions src/eeg_series.jl
Original file line number Diff line number Diff line change
@@ -63,9 +63,6 @@ function eeg_topoplot_series!(

topo_axis = update_axis(supportive_defaults(:topo_default_series); topo_axis...)

qminmax = @lift(extract_colorrange($data))
topo_attributes = update_axis(topo_attributes; colorrange = qminmax)

# do the col/row plot
axlist = []
if interactive_scatter != nothing
@@ -83,8 +80,7 @@ function eeg_topoplot_series!(
r = layout[t_idx][1]
c = layout[t_idx][2]
end
#@show r c topo_axis xlabels t_idx
#@show xlabels

ax = Axis(
fig[r, c];
topo_axis...,
@@ -109,7 +105,7 @@ function eeg_topoplot_series!(
if typeof(fig) != GridLayout && typeof(fig) != GridLayoutBase.GridSubposition
colgap!(fig.layout, 0)
end
return fig, axlist, topo_attributes[:colorrange]
return fig, axlist
end

function label_management(cat_or_cont_columns, df_single, col)
40 changes: 19 additions & 21 deletions src/plot_topoplotseries.jl
Original file line number Diff line number Diff line change
@@ -42,8 +42,6 @@ Multiple miniature topoplots in regular distances.
`mapping.col` - specify x-value, can be any continuous or categorical variable.\\
`mapping.row` - specify y-value, can be any continuous or categorical variable (not implemented yet).\\
`mapping.layout` - arranges topoplots by rows when equals `:time`.\\
- `visual.colorrange::2-element Vector{Int64}`\\
Resposnible for colorrange in topoplots and in colorbar.
- `topo_attributes::NamedTuple = (;)`\\
Here you can flexibly change configurations of the topoplot interoplation.\\
To see all options just type `?Topoplot.topoplot` in REPL.\\
@@ -71,6 +69,7 @@ function plot_topoplotseries!(
interactive_scatter = nothing,
topo_axis = (;),
topo_attributes = (;),
#uncertainty = false,
kwargs...,
)

@@ -107,7 +106,6 @@ function plot_topoplotseries!(
data_unstacked = @lift unstack($df_combined, :channel, :estimate_mean)
data_row = @lift Matrix($data_unstacked[:, 2:end])'


else
bins = @lift bins_estimation(
$data[!, config.mapping.col];
@@ -143,36 +141,36 @@ function plot_topoplotseries!(
rows, cols = row_col_management(to_value(n_topoplots), nrows, config)
layout = map((x, y) -> (x, y), to_value(rows), to_value(cols))

config_kwargs!(
config;
mapping = (; row = :row_coord, col = :col_coord),
axis = (; xlabel = string(config.mapping.col)),
)
config_kwargs!(config; kwargs...) #add the user specified once more, just if someone specifies the xlabel manually
# overkill as we would only need to check the xlabel ;)
ftopo, axlist, colorrange = eeg_topoplot_series!(
ftopo, axlist = eeg_topoplot_series!(
f[1, 1],
data_row;
layout,
xlabels,
#col_labels = col_labels, # TODO
#row_labels = row_labels, # TODO
rasterize_heatmaps = rasterize_heatmaps,
interactive_scatter = interactive_scatter,
topo_axis = topo_axis,
topo_attributes = topo_attributes,
#col_labels, # TODO
#row_labels, # TODO
rasterize_heatmaps,
interactive_scatter,
topo_axis,
topo_attributes,
positions,
labels,
)
cb_limits = (minimum(data_cuts.val.estimate), maximum(data_cuts.val.estimate)) # set limits for colorbar
cb_ticks = LinRange(cb_limits[1], cb_limits[2], 5) # set ticklables for colorbar
rounded_ticks = round.(cb_ticks, digits = 2)

config_kwargs!(
config,
visual = (; colorrange = colorrange),
colorbar = (; colorrange = colorrange),
config;
mapping = (; row = :row_coord, col = :col_coord),
axis = (; xlabel = string(config.mapping.col)),
colorbar = (; limits = cb_limits, ticks = (cb_ticks, string.(rounded_ticks))),
)
config_kwargs!(config; kwargs...) #add the user specified once more, just if someone specifies the xlabel manually
# overkill as we would only need to check the xlabel ;)

ax = Axis(
f[1, 1];
(p for p in pairs(config.axis) if p[1] != :xlim_topo && p[1] != :ylim_topo)...,
(p for p in pairs(config.axis) if p[1] != :xlim_topo && p[1] != :ylim_topo)..., # what it this??
)
if config.layout.use_colorbar == true
Colorbar(f[1, 2]; colormap = config.visual.colormap, config.colorbar...)
4 changes: 2 additions & 2 deletions src/plotconfig.jl
Original file line number Diff line number Diff line change
@@ -120,9 +120,9 @@ function PlotConfig(T::Val{:topoplotseries})
yrectzoom = false,
),
layout = (; use_colorbar = true),
colorbar = (; flipaxis = true, label = "Voltage", colorrange = nothing),
colorbar = (; flipaxis = true, label = "Voltage"),
visual = (;
label_text = false, # true doesnt work again
label_text = false,
colormap = Reverse(:RdBu),
enlarge = 1,
label_scatter = false,
18 changes: 0 additions & 18 deletions test/test_toposeries1.jl
Original file line number Diff line number Diff line change
@@ -198,24 +198,6 @@ end
plot_topoplotseries(df; bin_width, positions = positions, axis = (; xlabel = "test"))
end

@testset "toposeries: adjustable colorrange" begin
plot_topoplotseries(
df;
bin_width,
positions = positions,
visual = (; colorrange = (-3, 3)),
)
end

@testset "toposeries: visual.colorrange and colorbar.colorrange" begin
plot_topoplotseries(
df;
bin_width,
positions = positions,
colorbar = (; colorrange = (-1, 1)),
visual = (; colorrange = (-1, 1)),
)
end

@testset "toposeries: adjusted ylim_topo" begin
plot_topoplotseries(

0 comments on commit 981fa63

Please sign in to comment.