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
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
This Project is for the TU-Berlin Course "Julia Programming for Machine Learning"<br>
Please make sure, that Julia `1.10` is used!

This Module will return you a nice Scene you can use to display your Data with [Parallel Coordinates](https://en.wikipedia.org/wiki/Parallel_coordinates)<br>
<img src="test/projectile_simulation.png" width="300" />

_This Module was created with PkgTemplates.jl_
This Module will return you a nice Makie Plot you can use to display your Data with [Parallel Coordinates](https://en.wikipedia.org/wiki/Parallel_coordinates)<br>
<img src="test/projectile_simulation.png" width="500" />

## Getting Started

Expand All @@ -30,7 +28,6 @@ using ParallelPlots

| Parameter | Default | Example | Description |
|-------------------|----------|------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| normalize::Bool | false | normalize=true | If the Data should be normalized (min/max) |
| title::String | "" | title="My Title" | The Title of The Figure, |
| colormap | :viridis | colormap=:thermal | The Colors of the [Lines](https://docs.makie.org/dev/explanations/colors) |
| color_feature | nothing | color_feature="weight" | The Color of the Lines will be based on the values of this selected feature. If nothing, the last feature will be used |
Expand All @@ -46,10 +43,6 @@ julia> using ParallelPlots
julia> parallelplot(DataFrame(height=160:180,weight=60:80,age=20:40))
```
```
# If you want to normalize the Data, you can add the value normalized=true, default is false
julia> parallelplot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40),normalize=true)
```
```
# If you want to set the size of the plot (default width:800, height:600)
julia> parallelplot( DataFrame(height=160:180,weight=60:80,age=20:40), figure = (resolution = (300, 300),) )
```
Expand All @@ -69,7 +62,7 @@ julia> parallelplot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40), f
```
# Adjust Color and and feature
parallelplot(df,
# You choose which axis/feature should be in charge for the coloring
# You choose which axis/feature should be in charge for the coloring
color_feature="weight",
# you can as well select, which Axis should be shown
feature_selection=["height","age","income"],
Expand All @@ -84,8 +77,6 @@ parallelplot(df,
)
```

Please read the [Docs](/docs/build/index.html) for further Information

### Working on ParallelPlots / Cheatsheet
1. Using ParallelPlots
* Moving to the project folder
Expand Down
24 changes: 2 additions & 22 deletions src/ParallelPlots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ using DataFrames: DataFrame, names, eachcol, size, minimum, maximum



function normalize_DF(data::DataFrame)
for col in names(data)
data[!, col] = (data[!, col] .- minimum(data[!, col])) ./
(maximum(data[!, col]) - minimum(data[!, col]))
end

return data
end


function input_data_check(data::DataFrame)
if isnothing(data)
throw(ArgumentError("Data cannot be nothing"))
Expand All @@ -36,14 +26,13 @@ end

# Constructors
```julia
ParallelPlot(data::DataFrame; normalize::Bool=false)
ParallelPlot(data::DataFrame, _Arguments_)
```

# Arguments

| Parameter | Default | Example | Description |
|-------------------|----------|------------------------------------|------------------------------------------------------------------------------------------------------------------------|
| normalize::Bool | false | normalize=true | If the Data should be normalized (min/max) |
| title::String | "" | title="My Title" | The Title of The Figure, |
| colormap | :viridis | colormap=:thermal | The Colors of the [Lines](https://docs.makie.org/dev/explanations/colors) |
| color_feature | nothing | color_feature="weight" | The Color of the Lines will be based on the values of this selected feature. If nothing, the last feature will be used |
Expand All @@ -58,9 +47,6 @@ ParallelPlot(data::DataFrame; normalize::Bool=false)
julia> using ParallelPlots
julia> parallelplot(DataFrame(height=160:180,weight=60:80,age=20:40))

# If you want to normalize the Data, you can add the value normalized=true, default is false
julia> parallelplot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40),normalize=true)

# 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),) )

Expand Down Expand Up @@ -95,7 +81,6 @@ parallelplot(df,
@recipe(ParallelPlot, df) do scene
Attributes(
# additional attributes
normalize = false,
title = "", # Title of the Figure
colormap = :viridis, # https://docs.makie.org/dev/explanations/colors
color_feature = nothing, # Which feature to use for coloring (column name)
Expand All @@ -117,11 +102,6 @@ function Makie.plot!(pp::ParallelPlot)
# check the given DataFrame
input_data_check(data)

# Normalize the data if required
if pp.normalize[]
data = normalize_DF(data)
end

# Get the Fig and empty it, so its nice and clean for the next itaration
fig = current_figure()
empty!(fig)
Expand Down Expand Up @@ -237,7 +217,7 @@ function Makie.plot!(pp::ParallelPlot)
# add listener to Observable Arguments and trigger an update on change
# loop thorough the given Arguments
for kw in pp.kw
# e.g. normalize
# e.g. curve
attribute_key = kw[1]
on(pp[attribute_key]) do x
# trigger update
Expand Down
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include("test_argument_errors.jl")
include("test_curved.jl")
include("test_call_with_color_feature.jl")
include("test_call_with_feature_labels.jl")
include("test_call_with_normalize.jl")
include("test_custom_dimensions.jl")
include("test_default_call.jl")
include("test_recipe_observable.jl")
Expand Down
17 changes: 0 additions & 17 deletions test/test_call_with_normalize.jl

This file was deleted.

11 changes: 4 additions & 7 deletions test/test_recipe_observable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ using Test: @testset
@testset "Use a Observable DataFrame" begin

# create the Data
df_observable = Observable(create_person_df(2))
df_observable = Observable(create_person_df(3))
title_observable = Observable("")
normalize_observable = Observable(true)
curve_observable = Observable(true)

# create the Plot
fig, ax, sc = parallelplot(df_observable, normalize=normalize_observable, title=title_observable, curve = curve_observable)
fig, ax, sc = parallelplot(df_observable, title=title_observable, curve = curve_observable)
save("pcp_initialized.png", fig)

# we can change a parameter and the graph will be automaticly changed
Expand All @@ -24,15 +23,13 @@ using Test: @testset

# Update Dataframe
if(iseven(t))
normalize_observable[] = false
curve_observable[] = false
title_observable[] = ""
df_observable[] = create_person_df(5)
else
normalize_observable[] = true
curve_observable[] = true
title_observable[] = "Normalize"
df_observable[] = create_car_df(t)
title_observable[] = "Curved"
df_observable[] = create_car_df(t+1)
end


Expand Down
Loading