Skip to content

Commit

Permalink
topoplot
Browse files Browse the repository at this point in the history
  • Loading branch information
vladdez committed Nov 16, 2023
1 parent d958e5e commit 7c5dc9c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/plot_circulareegtopoplot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Plot a circular EEG topoplot.
- `f::Union{GridPosition, GridLayout, Figure}`: Figure, GridLayout or GridPosition that the plot should be drawn into
- `data::DataFrame`: DataFrame with keys for data (looks for `:y, :yhat, :estimate`), and :position (looks for `:pos, :position, :positions`),
- `predictor` (optional; default :predictor): the circular predictor value, defines position of topoplot, is mapped around `predictor_bounds`
- `predictor` (optional; default: predictor): the circular predictor value, defines position of topoplot, is mapped around `predictor_bounds`
- `predictor_bounds` (default: `[0,360]`): the bounds of the predictor. This is relevant for the axis labels.
- `positions` (default: nothing): positions for the [`plot_topoplot`](@Ref)
- `center_label` (default: ""): the text in the center of the cricle
Expand Down
24 changes: 12 additions & 12 deletions src/plot_parallelcoordinates.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
"""
plot_parallelcoordinates!(f::Union{GridPosition, GridLayout, Figure},
?\(f::Union{GridPosition, GridLayout, Figure},
data::DataFrame, config::PlotConfig; channels::Vector{Int64})
Plot a PCP (parallel coordinates plot).
## Arguments:
- `f::Union{GridPosition, GridLayout, Figure}`: Figure or GridPosition that the plot should be drawn into
- `data::DataFrame`: Data for the plot visualization.
- `config::PlotConfig`: Instance of PlotConfig being applied to the visualization.
- `f::Union{GridPosition, GridLayout, Figure}`: Figure or GridPosition that the plot should be drawn into.
- `data::DataFrame`: data for the plot visualization.
- `config::PlotConfig`: instance of PlotConfig being applied to the visualization.
- `channels::Vector{Int64}`: vector with all the channels representing an axis used in the PCP in given order.
PCP has problems with size changes of the view window.
By adapting the padding, aspect ratio and tick label size in px for a new use case, the PCP can even be added into a Coordinated Multiple Views System
- `pc_aspect_ratio` Default : `0.55`
- `pc_right_padding` Default : `15`
- `pc_left_padding` Default : `25`
- `pc_top_padding` Default : `26`
- `pc_bottom_padding` Default : `16`
- `pc_tick_label_size` Default : `14`
By adapting the padding, aspect ratio and tick label size in px for a new use case, the PCP can even be added into a complex figures.
- `pc_aspect_ratio` (default: `0.55`) -
- `pc_right_padding` (default: `15`) -
- `pc_left_padding` (default: `25`) -
- `pc_top_padding` (default: `26`) -
- `pc_bottom_padding` (default: `16`) -
- `pc_tick_label_size` (default: `14`) -
$(_docstring(:paracoord))
Expand Down
26 changes: 13 additions & 13 deletions src/plot_topoplot.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
plot_topoplot!(f::Union{GridPosition, GridLayout, Figure}, plotData, ; positions=nothing, labels=nothing,kwargs...)
plot_topoplot(plotData,; positions=nothing, labels=nothing, kwargs...)
plot_topoplot!(f::Union{GridPosition, GridLayout, Figure}, data, ; positions=nothing, labels=nothing,kwargs...)
plot_topoplot(data,; positions=nothing, labels=nothing, kwargs...)
Plot a topo plot.
## Arguments:
- `f::Union{GridPosition, GridLayout, Figure}`: Figure or GridPosition (e.g. f[2, 3]) that the plot should be drawn into. New axis is created.
- `plotData::Union{DataFrame, Vector{Float32}}`: Data for the plot visualization.
- `positions::Vector{Point{2, Float32}}=nothing`: positions used if `plotData` is no DataFrame. If this is the case and `positions=nothing` then positions is generated from `labels`.
- `labels::Vector{String}=nothing`: labels used if `plotData` is no DataFrame.
- `data::Union{DataFrame, Vector{Float32}}`: data for the plot visualization.
- `positions::Vector{Point{2, Float32}}=nothing`: positions used if `data` is not a DataFrame. If this is the case and `positions=nothing` then positions are generated from `labels`.
- `labels::Vector{String} = nothing`: labels used if `data` is not a DataFrame.
$(_docstring(:topoplot))
Expand All @@ -16,11 +16,11 @@ $(_docstring(:topoplot))
## Return Value:
A figure displaying the topo plot.
"""
plot_topoplot(plotData::Union{DataFrame,Vector{Float32}}; kwargs...) =
plot_topoplot!(Figure(), plotData; kwargs...)
plot_topoplot(data::Union{DataFrame,Vector{Float32}}; kwargs...) =
plot_topoplot!(Figure(), data; kwargs...)
function plot_topoplot!(
f::Union{GridPosition,GridLayout,Figure},
plotData::Union{DataFrame,<:AbstractVector};
data::Union{DataFrame,<:AbstractVector};
positions = nothing,
labels = nothing,
kwargs...,
Expand All @@ -31,16 +31,16 @@ function plot_topoplot!(
axis = Axis(f[1, 1]; config.axis...)


if !(plotData isa Vector)
config.mapping = resolveMappings(plotData, config.mapping)
plotData = plotData[:, config.mapping.y]
if !(data isa Vector)
config.mapping = resolveMappings(data, config.mapping)
data = data[:, config.mapping.y]
end

positions = getTopoPositions(; positions = positions, labels = labels)

eeg_topoplot!(axis, plotData, labels; positions, config.visual...)
eeg_topoplot!(axis, data, labels; positions, config.visual...)

clims = (min(plotData...), max(plotData...))
clims = (min(data...), max(data...))
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.
Expand Down

0 comments on commit 7c5dc9c

Please sign in to comment.