Skip to content

Commit 6c762b1

Browse files
authored
Merge pull request #19 from moritz155/feature/customize_graph
customize width and height of scene and make size of plot dependent o…
2 parents 5c604f0 + 2cc9c80 commit 6c762b1

4 files changed

Lines changed: 31 additions & 7 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ julia> ParallelPlots.create_parallel_coordinates_plot(DataFrame(height=160:180,w
3838
# If you want to normalize the Data, you can add the value normalized=true, default is false
3939
julia> ParallelPlots.create_parallel_coordinates_plot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40),normalize=true)
4040
41+
# If you want to set the size of the plot (default width:800, height:600)
42+
julia> ParallelPlots.create_parallel_coordinates_plot( DataFrame(height=160:180,weight=60:80,age=20:40), scene_width=200, scene_height=200 )
43+
4144
```
4245

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

src/ParallelPlots.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ end
4242
4343
# Constructors
4444
```julia
45-
ParallelPlots.create_parallel_coordinates_plot(data::DataFrame; normalize::Bool=false)
45+
ParallelPlots.create_parallel_coordinates_plot(data::DataFrame; normalize::Bool=false, scene_width::Integer=800, scene_height::Integer=600)
4646
```
4747
4848
# Arguments
@@ -57,12 +57,15 @@ julia> ParallelPlots.create_parallel_coordinates_plot(DataFrame(height=160:180,w
5757
# If you want to normalize the Data, you can add the value normalized=true, default is false
5858
julia> ParallelPlots.create_parallel_coordinates_plot(DataFrame(height=160:180,weight=reverse(60:80),age=20:40),normalize=true)
5959
60+
# If you want to set the size of the plot (default width:800, height:600)
61+
julia> ParallelPlots.create_parallel_coordinates_plot( DataFrame(height=160:180,weight=60:80,age=20:40), scene_width=200, scene_height=200 )
6062
6163
```
6264
6365
6466
"""
65-
function create_parallel_coordinates_plot(data::DataFrame; normalize::Bool=false)
67+
function create_parallel_coordinates_plot(data::DataFrame; normalize::Bool=false, scene_width::Integer=800, scene_height::Integer=600)
68+
input_check(data)
6669

6770
input_check(data)
6871

@@ -78,15 +81,15 @@ function create_parallel_coordinates_plot(data::DataFrame; normalize::Bool=false
7881
limits = [(minimum(col), maximum(col)) for col in parsed_data]
7982

8083
let
81-
scene = Scene(camera=campixel!)
82-
#TODO: Scene(resolution = (1200, 900), camera=campixel!)
84+
# creates the Scene for the Plot
85+
scene = Scene(resolution = (scene_width, scene_height), camera=campixel!)
8386
numberFeatures = length(parsed_data) # Number of features, equivalent to the X Axis
8487
sampleSize = size(data, 1) # Number of samples, equivalent to the Y Axis
8588

8689
# Plot dimensions
87-
width = 600
88-
height = 400
89-
offset = 100
90+
width = scene_width * 0.75 # 75% of scene width
91+
height = scene_height * 0.75 # 75% of scene width
92+
offset = min(scene_width, scene_height) * 0.15 # 15% of scene dimensions
9093

9194
# Create axes
9295
for i in 1:numberFeatures

test/parallel_coordinates_plot.png

-103 KB
Loading

test/runtests.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ end
4444
ParallelPlots.create_parallel_coordinates_plot(df_one_line)
4545
end
4646
end
47+
4748
@testset "default call" begin
4849

4950
# Generate sample multivariate data
@@ -75,3 +76,20 @@ end
7576
display(fig)
7677

7778
end
79+
80+
@testset "call with scene width & height" begin
81+
82+
# Generate sample multivariate data
83+
df = create_person_df()
84+
85+
#display
86+
fig = ParallelPlots.create_parallel_coordinates_plot(df, scene_width = 300, scene_height = 300)
87+
88+
@test fig !== nothing
89+
90+
print(fig)
91+
92+
save("parallel_coordinates_plot_300x300.png", fig)
93+
display(fig)
94+
95+
end

0 commit comments

Comments
 (0)