Skip to content

Commit 327f293

Browse files
author
Mohammed Sadique
committed
bubble
1 parent 3071b2c commit 327f293

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

lib/matplotex/colorscheme/colormap.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ defmodule Matplotex.Colorscheme.Colormap do
2828
|> Enum.map(&colormap(&1, size))
2929
end
3030

31+
def default_cmap(), do: viridis()
32+
3133
defp colormap({color, idx}, size) do
3234
offset = idx / size * 100
3335
%__MODULE__{color: color, offset: offset}

lib/matplotex/colorscheme/garner.ex

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@ defmodule Matplotex.Colorscheme.Garner do
22
alias Matplotex.Colorscheme.Rgb
33
alias Matplotex.Colorscheme.Blender
44
alias Matplotex.InputError
5-
alias Matplotex.Colorscheme.Colormap
65

76
defstruct [:range, :color_cue, :cmap, :preceeding, :minor, :major, :final]
87

98
def garn_color({min, max} = range, point, cmap) when max != min do
109
cue = (point - min) / (max - min)
1110
cmap
12-
|> fetch_from_cmap()
11+
|> make_from_cmap()
1312
|> put_range(range, cue)
1413
|> point_color()
1514
end
1615

17-
defp fetch_from_cmap(cmap) do
16+
defp make_from_cmap(cmap) do
1817
cmap
19-
|>Colormap.fetch_cmap()
2018
|>to_rgb()
2119
|>place_edges()
2220
end

test/matplotex/figure/areal/scatter_test.exs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,18 @@ defmodule Matplotex.Figure.Areal.ScatterTest do
1212
assert %Figure{axes: %{data: {x, _y}, element: elements}} = Scatter.materialize(figure)
1313
assert Enum.count(elements, fn elem -> elem.type == "plot.marker" end) == length(x)
1414
end
15+
test "adds point with specific color with color scheme" do
16+
x = [1, 3, 7, 4, 2, 5, 6]
17+
y = [1, 3, 7, 4, 2, 5, 6]
18+
colors = [1, 3, 7, 4, 2, 5, 6]
1519

20+
assert %Figure{axes: %{element: elements}} = x
21+
|> Matplotex.scatter(y, colors: colors)
22+
|> Matplotex.figure(%{figsize: size, margin: margin})
23+
|> Scatter.materialize()
24+
25+
assert elements|>Enum.filter(fn elem -> elem.type == "point.color" end)|>length()
26+
end
1627
end
1728

1829
describe "generate_ticks/2" do

0 commit comments

Comments
 (0)