Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
ParallelPlots = "79f8b2c9-78a2-4289-b087-49f7cf65a4c9"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DrWatson = "634d3b9d-ee7a-5ddf-bec9-22491ea816e1"
50 changes: 44 additions & 6 deletions src/ParallelPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ checks the Input Data if the size is correct and no missing values are available
Throws error on wrong DF
"""
function input_data_check(data::DataFrame)
if isnothing(data)
throw(ArgumentError("Data cannot be nothing"))
end
if size(data, 2) < 2 # otherwise there will be a nullpointer exception later
throw(ArgumentError("Data must have at least two columns, currently ("*string(size(data, 2))*")"))
end
Expand Down Expand Up @@ -62,13 +59,52 @@ FigureAxisPlot()
julia> display(fig)
CairoMakie.Screen{IMAGE}
```
Using DrWatson with ParallelPlot
```jldoctest
julia> using DataFrames, DrWatson, ParallelPlots

julia> function exec_simulation(d::Dict, results)
@unpack launch_angles, initial_velocities = d
max_height = initial_velocities * launch_angles
push!(results, [
initial_velocities,
launch_angles,
max_height,
])
return results
end;

julia> initial_velocities = [40.0, 50.0];

julia> launch_angles = [30.0, 60.0];

julia> allparams = Dict(
"initial_velocities" => initial_velocities,
"launch_angles" => launch_angles,
);

julia> dicts = dict_list(allparams);

julia> results = DataFrame(
initial_velocity=Float64[],
launch_angle=Float64[],
max_height=Float64[],
);

julia> for d in dicts
results = exec_simulation(d, results)
end;

julia> fig = parallelplot(results, curve=true, figure = (size = (1000, 600),));

julia> display(fig);
```
```@example
# If you want to set the size of the plot
julia> parallelplot( DataFrame(height=160:180,weight=60:80,age=20:40), figure = (resolution = (300, 300),) )
```
```
# You can update as well the Graph with Observables
# You can update the Graph with Observables as well
julia> df_observable = Observable(DataFrame(height=160:180,weight=60:80,age=20:40))
julia> fig, ax, sc = parallelplot(df_observable)
```
Expand All @@ -81,7 +117,7 @@ julia> parallelplot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40),ti
julia> parallelplot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40), feature_labels=["Height","Weight","Age"])
```
```
# Adjust Color and and feature
# Adjust Color and and Feature
parallelplot(df,
# You choose which axis/feature should be in charge for the coloring
color_feature="weight",
Expand Down Expand Up @@ -119,7 +155,9 @@ function Makie.plot!(pp::ParallelPlot)
# this helper function will update our observables
# whenever df_observable change
function update_plot(data)

if isnothing(data)
throw(ArgumentError("Data cannot be nothing"))
end
# check the given DataFrame
input_data_check(data)

Expand Down
3 changes: 3 additions & 0 deletions test/test_argument_errors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ using CairoMakie: save
@test_throws ArgumentError begin
parallelplot(df_one_line)
end
@test_throws ArgumentError begin
parallelplot(nothing)
end
end
Loading