@@ -14,6 +14,17 @@ defmodule Matplotex.Figure.Areal.ScatterTest do
1414 assert % Figure { axes: % { data: { x , _y } , element: elements } } = Scatter . materialize ( figure )
1515 assert Enum . count ( elements , fn elem -> elem . type == "plot.marker" end ) == length ( x )
1616 end
17+ test "generates elements with various saizes if it passed a size attrbute" do
18+ x = [ 1 , 2 , 3 , 4 , 5 ]
19+ y = [ 10 , 20 , 30 , 40 , 50 ]
20+ sizes = [ 1 , 2 , 3 , 4 , 5 ]
21+ assert % Figure { axes: % { element: elements } } = x |> Matplotex . scatter ( y , sizes: sizes ) |> Figure . materialize ( )
22+ [ h | tail ] = elements |> Enum . filter ( fn x -> x . type == "plot.marker" end ) |> Enum . map ( fn x ->
23+ x . r
24+ end )
25+ refute Enum . all? ( tail , fn x -> x == h end )
26+
27+ end
1728 end
1829
1930 describe "generate_ticks/2" do
@@ -38,6 +49,16 @@ defmodule Matplotex.Figure.Areal.ScatterTest do
3849 assert Enum . all? ( transformed , & match? ( { { _ , _ } , _ } , & 1 ) )
3950
4051 end
52+ test "zips transformed values with marker size if colors exist without sizes" do
53+ x = [ 1 , 2 , 3 , 4 , 5 ]
54+ y = [ 10 , 20 , 30 , 40 , 50 ]
55+ colors = [ 1 , 2 , 3 , 4 , 5 ]
56+ width = 2
57+ height = 2
58+ assert % Figure { axes: % { dataset: [ % Dataset { marker_size: _marker_size } = dataset ] } } = x |> Matplotex . scatter ( y , figsize: { width , height } , colors: colors )
59+ assert % Dataset { transformed: transformed } = Areal . do_transform ( dataset , Enum . min_max ( x ) , Enum . min_max ( y ) , width , height , { 0 , 0 } )
60+ assert Enum . all? ( transformed , & match? ( { { { _ , _ } , _marker_size } , _ } , & 1 ) )
61+ end
4162 test "zips transformed values with colors if the dataset contanis colors" do
4263 x = [ 1 , 2 , 3 , 4 , 5 ]
4364 y = [ 10 , 20 , 30 , 40 , 50 ]
@@ -47,7 +68,7 @@ defmodule Matplotex.Figure.Areal.ScatterTest do
4768 assert % Figure { axes: % { dataset: [ dataset ] } } = x |> Matplotex . scatter ( y , figsize: { width , height } , colors: colors )
4869 assert % Dataset { transformed: transformed } = Areal . do_transform ( dataset , Enum . min_max ( x ) , Enum . min_max ( y ) , width , height , { 0 , 0 } )
4970
50- assert Enum . all? ( transformed , & match? ( { { _ , _ } , _ } , & 1 ) )
71+ assert Enum . all? ( transformed , & match? ( { { { _ , _ } , _ } , _ } , & 1 ) )
5172
5273 end
5374
@@ -64,5 +85,8 @@ defmodule Matplotex.Figure.Areal.ScatterTest do
6485 assert Enum . all? ( transformed , & match? ( { { { _ , _ } , _ } , _ } , & 1 ) )
6586
6687 end
88+
6789 end
90+
91+
6892end
0 commit comments