diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
new file mode 100644
index 0000000..de1b8df
--- /dev/null
+++ b/.github/workflows/CI.yml
@@ -0,0 +1,36 @@
+name: CI
+on:
+ pull_request:
+ branches:
+ - master
+ push:
+ branches:
+ - master
+ tags: '*'
+jobs:
+ test:
+ name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
+ runs-on: ${{ matrix.os }}
+ strategy:
+ fail-fast: false
+ matrix:
+ version:
+ - '1.10'
+ - '1' # This automatically expands to the latest stable 1.x release.
+ os:
+ - ubuntu-latest
+ - macos-latest
+ - windows-latest
+ arch:
+ - x64
+ steps:
+ - uses: actions/checkout@v4
+ - uses: julia-actions/setup-julia@v2
+ with:
+ version: ${{ matrix.version }}
+ arch: ${{ matrix.arch }}
+ - uses: julia-actions/cache@v2
+ - uses: julia-actions/julia-buildpkg@v1
+ - uses: julia-actions/julia-runtest@v1
+ with:
+ prefix: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' #"headless", i.e., without display, as CI server doesn't have a monitor
diff --git a/Project.toml b/Project.toml
index a6652f2..f3c7194 100644
--- a/Project.toml
+++ b/Project.toml
@@ -7,20 +7,30 @@ version = "0.1.2"
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
GeometricalPredicates = "fd0ad045-b25c-564e-8f9c-8ef5c5f21267"
-LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
VoronoiDelaunay = "72f80fcb-8c52-57d9-aff0-40c1a3526986"
[compat]
-julia = "1"
+Aqua = "0.8"
+ColorSchemes = "3"
+DocStringExtensions = "0.9"
GeometricalPredicates = "0.4"
+GLMakie = "0.9, 0.10"
+JLD2 = "0.5"
+Makie = "0.20, 0.21"
+ReferenceTests = "0.10"
+SafeTestsets = "0.1"
+Test = "1"
VoronoiDelaunay = "0.4"
-DocStringExtensions = "0.9"
-ColorSchemes = "3"
-Makie = "0.2"
+julia = "1"
[extras]
+Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
+GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
+JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
+ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
+SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[targets]
-test = ["Test"]
+test = ["Aqua", "GLMakie", "JLD2", "ReferenceTests", "SafeTestsets", "Test"]
diff --git a/README.md b/README.md
index ef03c37..431161b 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# TernaryDiagrams
[repostatus-url]: https://www.repostatus.org/#active
[repostatus-img]: https://www.repostatus.org/badges/latest/active.svg
+[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
[![repostatus-img]][repostatus-url] [![TernaryDiagrams Downloads](https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/TernaryDiagrams)](https://pkgs.genieframework.com?packages=TernaryDiagrams)
@@ -9,15 +10,11 @@ that can be used to construct a (relatively quick and dirty) [ternary
plot](https://en.wikipedia.org/wiki/Ternary_plot).
In all the examples that follow, it is assumed that `a1[i] + a2[i] + a3[i] = 1`.
-If applicable, `w[i]` corresponds to the weight associated with the point
-`(a1[i], a2[i], a3[i])` for each index `i` in the dataset. If you would like to
-load a test dataset, use `test/data.jld2`, which can be opened with
-[JLD2.jl](https://github.com/JuliaIO/JLD2.jl). The file contains `a1`, `a2`,
-`a3` and `mus`, with the latter being weights associated with the data points.
-See the file `temp.jl` for an example of its usage.
## The ternary axis
```julia
+using GLMakie
+using TernaryDiagrams
fig = Figure();
ax = Axis(fig[1, 1]);
@@ -42,16 +39,24 @@ fig
```
-
+
## Ternary lines
```julia
-fig = Figure();
-ax = Axis(fig[1, 1]);
-
-ternaryaxis!(ax);
+using GLMakie
+using TernaryDiagrams
+using JLD2
+@load pkgdir(TernaryDiagrams)*"\\test\\data.jld2" a1 a2 a3 mus
+a1 = a1[1:20]
+a2 = a2[1:20]
+a3 = a3[1:20]
+
+fig = Figure()
+ax = Axis(fig[1, 1])
+
+ternaryaxis!(ax)
ternarylines!(ax, a1, a2, a3; color = :blue)
xlims!(ax, -0.2, 1.2)
@@ -61,23 +66,31 @@ fig
```
-
+
## Ternary scatter
```julia
-
-fig = Figure();
-ax = Axis(fig[1, 1]);
-
-ternaryaxis!(ax);
+using GLMakie
+using TernaryDiagrams
+using JLD2
+@load pkgdir(TernaryDiagrams)*"\\test\\data.jld2" a1 a2 a3 mus
+a1 = a1[1:20]
+a2 = a2[1:20]
+a3 = a3[1:20]
+mus = mus[1:20]
+
+fig = Figure()
+ax = Axis(fig[1, 1])
+
+ternaryaxis!(ax)
ternaryscatter!(
ax,
a1,
a2,
a3;
- color = [get(ColorSchemes.Spectral, w, extrema(ws)) for w in ws],
+ color = [get(Makie.ColorSchemes.Spectral, w, extrema(mus)) for w in mus],
marker = :circle,
markersize = 20,
)
@@ -89,12 +102,20 @@ fig
```
-
+
## Ternary contours
```julia
+using GLMakie
+using TernaryDiagrams
+using JLD2
+@load pkgdir(TernaryDiagrams)*"\\test\\data.jld2" a1 a2 a3 mus
+a1 = a1[1:20]
+a2 = a2[1:20]
+a3 = a3[1:20]
+mus = mus[1:20]
fig = Figure();
ax = Axis(fig[1, 1]);
@@ -103,15 +124,15 @@ ternarycontour!(
a1,
a2,
a3,
- ws;
+ mus;
levels = 5,
linewidth = 4,
color = nothing,
- colormap = reverse(ColorSchemes.Spectral),
+ colormap = reverse(Makie.ColorSchemes.Spectral),
pad_data = true,
)
-ternaryaxis!(ax);
+ternaryaxis!(ax)
xlims!(ax, -0.2, 1.2)
ylims!(ax, -0.3, 1.1)
@@ -120,7 +141,7 @@ fig
```
-
+
@@ -128,11 +149,19 @@ fig
Note: `ternarycontour` uses a different Delaunay triangulation scheme to
`ternarycontourf` (the former is made by me, while the latter essentially calls
`tricontourf` from Makie.
-from Makie internally).
+
```julia
+using GLMakie
+using TernaryDiagrams
+using JLD2
+@load pkgdir(TernaryDiagrams)*"\\test\\data.jld2" a1 a2 a3 mus
+a1 = a1[1:20]
+a2 = a2[1:20]
+a3 = a3[1:20]
+mus = mus[1:20]
fig = Figure();
ax = Axis(fig[1, 1]);
-ternarycontourf!(ax, a1, a2, a3, ws; levels = 10)
+ternarycontourf!(ax, a1, a2, a3, mus; levels = 10)
ternaryaxis!(ax);
xlims!(ax, -0.2, 1.2)
ylims!(ax, -0.3, 1.1)
@@ -141,7 +170,7 @@ fig
```
-
+
diff --git a/figs/axis.png b/figs/axis.png
new file mode 100644
index 0000000..25ba83f
Binary files /dev/null and b/figs/axis.png differ
diff --git a/figs/axis.svg b/figs/axis.svg
deleted file mode 100644
index 4079cad..0000000
--- a/figs/axis.svg
+++ /dev/null
@@ -1,691 +0,0 @@
-
-
diff --git a/figs/contour.png b/figs/contour.png
new file mode 100644
index 0000000..f82bef3
Binary files /dev/null and b/figs/contour.png differ
diff --git a/figs/contour.svg b/figs/contour.svg
deleted file mode 100644
index 369fe15..0000000
--- a/figs/contour.svg
+++ /dev/null
@@ -1,846 +0,0 @@
-
-
diff --git a/figs/contourf.svg b/figs/contourf.svg
deleted file mode 100644
index db098c0..0000000
--- a/figs/contourf.svg
+++ /dev/null
@@ -1,851 +0,0 @@
-
-
diff --git a/figs/contourfill.png b/figs/contourfill.png
new file mode 100644
index 0000000..2ab66be
Binary files /dev/null and b/figs/contourfill.png differ
diff --git a/figs/contourfill.svg b/figs/contourfill.svg
deleted file mode 100644
index db098c0..0000000
--- a/figs/contourfill.svg
+++ /dev/null
@@ -1,851 +0,0 @@
-
-
diff --git a/figs/lines.png b/figs/lines.png
new file mode 100644
index 0000000..b57d984
Binary files /dev/null and b/figs/lines.png differ
diff --git a/figs/lines.svg b/figs/lines.svg
deleted file mode 100644
index 14d749c..0000000
--- a/figs/lines.svg
+++ /dev/null
@@ -1,842 +0,0 @@
-
-
diff --git a/figs/scatter.png b/figs/scatter.png
new file mode 100644
index 0000000..7e6f066
Binary files /dev/null and b/figs/scatter.png differ
diff --git a/figs/scatter.svg b/figs/scatter.svg
deleted file mode 100644
index 01c036e..0000000
--- a/figs/scatter.svg
+++ /dev/null
@@ -1,861 +0,0 @@
-
-
diff --git a/figs/temp.png b/figs/temp.png
new file mode 100644
index 0000000..e9ade6f
Binary files /dev/null and b/figs/temp.png differ
diff --git a/figs/test.png b/figs/test.png
deleted file mode 100644
index dc9aab5..0000000
Binary files a/figs/test.png and /dev/null differ
diff --git a/src/TernaryDiagrams.jl b/src/TernaryDiagrams.jl
index b790032..99c5abc 100644
--- a/src/TernaryDiagrams.jl
+++ b/src/TernaryDiagrams.jl
@@ -1,7 +1,7 @@
module TernaryDiagrams
-using Makie, LinearAlgebra, ColorSchemes, DocStringExtensions
-import GeometricalPredicates, VoronoiDelaunay, Base
+using Makie, ColorSchemes, DocStringExtensions
+using GeometricalPredicates, VoronoiDelaunay
const vd = VoronoiDelaunay
const gp = GeometricalPredicates
@@ -30,11 +30,11 @@ delaunay_unscale(x, y) = [(x - 1.1) / 0.8, (y - 1.1) / 0.8]
unpack(p::gp.Point2D) = (p._x, p._y)
-# extend some functions to work with Point2D from GeometricalPredicates
-Base.:(-)(a::gp.Point2D, b::gp.Point2D) = gp.Point2D(a._x - b._x, a._y - b._y)
-Base.:(+)(a::gp.Point2D, b::gp.Point2D) = gp.Point2D(a._x + b._x, a._y + b._y)
-Base.:(*)(a::gp.Point2D, b::Float64) = gp.Point2D(a._x * b, a._y * b)
-LinearAlgebra.norm(a::gp.Point2D) = sqrt(a._x^2 + a._y^2)
+# add/subtract/multiply and norm for Point2D from GeometricalPredicates
+pointsubtract(a::gp.Point2D, b::gp.Point2D) = gp.Point2D(a._x - b._x, a._y - b._y)
+pointadd(a::gp.Point2D, b::gp.Point2D) = gp.Point2D(a._x + b._x, a._y + b._y)
+pointmult(a::gp.Point2D, b::Float64) = gp.Point2D(a._x * b, a._y * b)
+normpointdiff(p1, p2) = (getx(p1) - getx(p2))^2 + (gety(p1) - gety(p2))^2
include("contour_funcs.jl")
diff --git a/src/axis.jl b/src/axis.jl
index 5b7fab1..fe56ae2 100644
--- a/src/axis.jl
+++ b/src/axis.jl
@@ -4,23 +4,26 @@ end
function draw_triangle_vertex_labels!(tr::TernaryAxis)
y_adj = tr.label_vertex_vertical_adjustment[]
- text!(
+ xlabelpos = r1 .+ [0, -y_adj]
+ ylabelpos = r2 .+ [0, -y_adj]
+ zlabelpos = r3 .+ [0, y_adj]
+ text!(
tr,
- Point2(r3...) + Point(0, y_adj);
+ zlabelpos...;
text = tr.labelz[],
align = (:center, :center),
fontsize = tr.label_fontsize[] * !tr.hide_vertex_labels[],
)
text!(
tr,
- Point2(r2...) + Point(0, -y_adj);
+ ylabelpos...;
text = tr.labely[],
align = (:left, :center),
fontsize = tr.label_fontsize[] * !tr.hide_vertex_labels[],
)
text!(
tr,
- Point2(r1...) + Point2(0, -y_adj);
+ xlabelpos...;
text = tr.labelx[],
align = (:right, :center),
fontsize = tr.label_fontsize[] * !tr.hide_vertex_labels[],
@@ -171,6 +174,5 @@ function Makie.plot!(tr::TernaryAxis)
draw_triangle_vertex_labels!(tr)
draw_triangle_axis_labels!(tr)
draw_grid!(tr)
-
tr
end
diff --git a/src/contour_funcs.jl b/src/contour_funcs.jl
index 39d1d01..fc38622 100644
--- a/src/contour_funcs.jl
+++ b/src/contour_funcs.jl
@@ -37,12 +37,11 @@ function generate_padded_data(data_coords, ws)
pad_weights = Float64[]
for p in pad_coords # TODO use nearest neighbor interpolant instead
- ds = [norm(p - x) for x in data_coords]
+ ds = [normpointdiff(p, x) for x in data_coords]
# idxs = sortperm(ds)[1:15] # this can be optimized
# dtot = sum(ds[idxs])
# w = sum(ws[idx] * ds[idx] / dtot for idx in idxs)
# push!(pad_weights, w)
-
idx = argmin(ds)
push!(pad_weights, ws[idx])
end
@@ -80,19 +79,19 @@ function split_edges(edges::Vector{Edge})
for (i, e_idx) in enumerate(edge_idxs)
edge = edges[e_idx]
for (c_idx, curve) in enumerate(curves)
- if norm(last(curve) - first(edge)) < TOL # from global tolerance
+ if normpointdiff(last(curve), first(edge)) < TOL # from global tolerance
curves[c_idx] = [curve; last(edge)]
used_edge_idx = i
break
- elseif norm(last(curve) - last(edge)) < TOL
+ elseif normpointdiff(last(curve), last(edge)) < TOL
curves[c_idx] = [curve; first(edge)]
used_edge_idx = i
break
- elseif norm(first(curve) - last(edge)) < TOL
+ elseif normpointdiff(first(curve), last(edge)) < TOL
curves[c_idx] = [first(edge); curve]
used_edge_idx = i
break
- elseif norm(first(curve) - first(edge)) < TOL
+ elseif normpointdiff(first(curve), first(edge)) < TOL
curves[c_idx] = [last(edge); curve]
used_edge_idx = i
break
@@ -143,8 +142,8 @@ function contour_triangle(scaled_coords, bins, weights, levels)
end
frac = (bins[level] - low_v) / (high_v - low_v)
- d = p_high - p_low
- return d * frac + p_low
+ d = pointsubtract(p_high, p_low)
+ return pointadd(pointmult(d, frac), p_low)
end
level_edges = Dict{Int64,Vector{Edge}}()
@@ -152,15 +151,15 @@ function contour_triangle(scaled_coords, bins, weights, levels)
for triangle in tess
for level = 1:levels
a = gp.geta(triangle)
- a_idx = argmin(norm(x - a) for x in scaled_coords)
+ a_idx = argmin(normpointdiff(x, a) for x in scaled_coords)
a_above = above_isovalue(weights[a_idx], level, bins)
b = gp.getb(triangle)
- b_idx = argmin(norm(x - b) for x in scaled_coords)
+ b_idx = argmin(normpointdiff(x, b) for x in scaled_coords)
b_above = above_isovalue(weights[b_idx], level, bins)
c = gp.getc(triangle)
- c_idx = argmin(norm(x - c) for x in scaled_coords)
+ c_idx = argmin(normpointdiff(x, c) for x in scaled_coords)
c_above = above_isovalue(weights[c_idx], level, bins)
p_ab = nothing
@@ -222,7 +221,7 @@ function rem_repeats(coords, weights)
for (coord, weight) in zip(coords, weights)
repeated = false
for u_coord in u_coords
- if norm(coord - u_coord) < TOL
+ if normpointdiff(coord, u_coord) < TOL
repeated = true
break
end
diff --git a/temp.jl b/temp.jl
deleted file mode 100644
index 6afb8c4..0000000
--- a/temp.jl
+++ /dev/null
@@ -1,54 +0,0 @@
-using CairoMakie
-using ColorSchemes
-using TernaryDiagrams
-using JLD2
-
-a1 = load("test/data.jld2", "a1")
-a2 = load("test/data.jld2", "a2")
-a3 = load("test/data.jld2", "a3")
-ws = Float64.(load("test/data.jld2", "mus"))
-
-fig = Figure();
-ax = Axis(fig[1, 1]);
-
-ternarycontourf!(
- ax,
- a1,
- a2,
- a3,
- ws;
- levels = 10,
- linewidth = 4,
- color = nothing,
- colormap = reverse(ColorSchemes.Spectral),
- pad_data = true,
-)
-
-ternaryscatter!(
- ax,
- a1,
- a2,
- a3;
- color = :black,
- marker = :circle,
- markersize = 15,
-)
-
-ternaryscatter!(
- ax,
- a1,
- a2,
- a3;
- color = [get(reverse(ColorSchemes.Spectral), w, extrema(ws)) for w in ws],
- marker = :circle,
- markersize = 10,
-)
-
-ternaryaxis!(ax);
-
-xlims!(ax, -0.2, 1.2)
-ylims!(ax, -0.3, 1.1)
-hidedecorations!(ax)
-fig
-
-Makie.FileIO.save("figs/test.png", fig)
diff --git a/test/aqua.jl b/test/aqua.jl
new file mode 100644
index 0000000..ebf5029
--- /dev/null
+++ b/test/aqua.jl
@@ -0,0 +1,2 @@
+using Aqua, TernaryDiagrams
+Aqua.test_all(TernaryDiagrams, ambiguities = false)
diff --git a/test/axis.jl b/test/axis.jl
deleted file mode 100644
index 847857c..0000000
--- a/test/axis.jl
+++ /dev/null
@@ -1,24 +0,0 @@
-using Revise
-using CairoMakie
-using ColorSchemes
-using TernaryDiagrams
-
-const td = TernaryDiagrams
-
-fig = Figure();
-ax = Axis(fig[1, 1]);
-
-ternaryaxis!(
- ax;
- labelx = "a1",
- labely = "a2",
- labelz = "a3",
- # more options available, check out attributes with ?ternaryaxis
-)
-
-xlims!(ax, -0.2, 1.2) # to center the triangle
-ylims!(ax, -0.3, 1.1) # to center the triangle
-hidedecorations!(ax) # to hide the axis decos
-fig
-
-Makie.FileIO.save("figs/axis.svg", fig)
diff --git a/test/contour.jl b/test/contour.jl
deleted file mode 100644
index d4cad1f..0000000
--- a/test/contour.jl
+++ /dev/null
@@ -1,34 +0,0 @@
-using CairoMakie
-using ColorSchemes
-using TernaryDiagrams
-using JLD2
-
-a1 = load("test/data.jld2", "a1")
-a2 = load("test/data.jld2", "a2")
-a3 = load("test/data.jld2", "a3")
-ws = Float64.(load("test/data.jld2", "mus"))
-
-fig = Figure();
-ax = Axis(fig[1, 1]);
-
-ternarycontour!(
- ax,
- a1,
- a2,
- a3,
- ws;
- levels = 5,
- linewidth = 4,
- color = nothing,
- colormap = reverse(ColorSchemes.Spectral),
- pad_data = true,
-)
-
-ternaryaxis!(ax);
-
-xlims!(ax, -0.2, 1.2)
-ylims!(ax, -0.3, 1.1)
-hidedecorations!(ax)
-fig
-
-Makie.FileIO.save("figs/contour.svg", fig)
diff --git a/test/contourfill.jl b/test/contourfill.jl
deleted file mode 100644
index ce4bbb1..0000000
--- a/test/contourfill.jl
+++ /dev/null
@@ -1,20 +0,0 @@
-using Revise
-using CairoMakie
-using TernaryDiagrams
-using JLD2
-
-a1 = load("test/data.jld2", "a1")
-a2 = load("test/data.jld2", "a2")
-a3 = load("test/data.jld2", "a3")
-ws = Float64.(load("test/data.jld2", "mus"))
-
-fig = Figure();
-ax = Axis(fig[1, 1]);
-ternarycontourf!(ax, a1, a2, a3, ws; levels = 10)
-ternaryaxis!(ax);
-xlims!(ax, -0.2, 1.2)
-ylims!(ax, -0.3, 1.1)
-hidedecorations!(ax)
-fig
-
-Makie.FileIO.save("figs/contourfill.svg", fig)
diff --git a/test/lines.jl b/test/lines.jl
deleted file mode 100644
index f5010fe..0000000
--- a/test/lines.jl
+++ /dev/null
@@ -1,22 +0,0 @@
-using CairoMakie
-using ColorSchemes
-using TernaryDiagrams
-using JLD2
-const td = TernaryDiagrams
-
-a1 = load("test/data.jld2", "a1")[1:20]
-a2 = load("test/data.jld2", "a2")[1:20]
-a3 = load("test/data.jld2", "a3")[1:20]
-
-fig = Figure();
-ax = Axis(fig[1, 1]);
-
-ternaryaxis!(ax);
-ternarylines!(ax, a1, a2, a3; color = :blue)
-
-xlims!(ax, -0.2, 1.2)
-ylims!(ax, -0.3, 1.1)
-hidedecorations!(ax)
-fig
-
-Makie.FileIO.save("figs/lines.svg", fig)
diff --git a/test/referencetests.jl b/test/referencetests.jl
new file mode 100644
index 0000000..cd3c1ca
--- /dev/null
+++ b/test/referencetests.jl
@@ -0,0 +1,152 @@
+using GLMakie
+#using ColorSchemes
+using TernaryDiagrams
+using JLD2
+using ReferenceTests
+
+@load pkgdir(TernaryDiagrams)*"\\test\\data.jld2" a1 a2 a3 mus
+a1 = a1[1:20]
+a2 = a2[1:20]
+a3 = a3[1:20]
+mus = mus[1:20]
+
+function testimage_axis()
+ fig = Figure();
+ ax = Axis(fig[1, 1]);
+
+ ternaryaxis!(
+ ax;
+ labelx = "a1",
+ labely = "a2",
+ labelz = "a3",
+ # more options available, check out attributes with ?ternaryaxis
+ )
+
+ xlims!(ax, -0.2, 1.2) # to center the triangle
+ ylims!(ax, -0.3, 1.1) # to center the triangle
+ hidedecorations!(ax) # to hide the axis decos
+ fig
+end
+
+function testimage_lines()
+ fig = Figure();
+ ax = Axis(fig[1, 1]);
+
+ ternaryaxis!(ax);
+ ternarylines!(ax, a1, a2, a3; color = :blue)
+
+ xlims!(ax, -0.2, 1.2)
+ ylims!(ax, -0.3, 1.1)
+ hidedecorations!(ax)
+ fig
+end
+
+function testimage_scatter()
+ fig = Figure();
+ ax = Axis(fig[1, 1]);
+
+ ternaryaxis!(ax);
+ ternaryscatter!(
+ ax,
+ a1,
+ a2,
+ a3;
+ color = [get(Makie.ColorSchemes.Spectral, w, extrema(mus)) for w in mus],
+ marker = :circle,
+ markersize = 20,
+ )
+
+ xlims!(ax, -0.2, 1.2)
+ ylims!(ax, -0.3, 1.1)
+ hidedecorations!(ax)
+ fig
+end
+
+function testimage_contour()
+ fig = Figure();
+ ax = Axis(fig[1, 1]);
+
+ ternarycontour!(
+ ax,
+ a1,
+ a2,
+ a3,
+ mus;
+ levels = 5,
+ linewidth = 4,
+ color = nothing,
+ colormap = reverse(Makie.ColorSchemes.Spectral),
+ pad_data = true,
+ )
+
+ ternaryaxis!(ax);
+
+ xlims!(ax, -0.2, 1.2)
+ ylims!(ax, -0.3, 1.1)
+ hidedecorations!(ax)
+ fig
+end
+
+function testimage_contourf()
+ fig = Figure();
+ ax = Axis(fig[1, 1]);
+ ternarycontourf!(ax, a1, a2, a3, mus; levels = 10)
+ ternaryaxis!(ax);
+ xlims!(ax, -0.2, 1.2)
+ ylims!(ax, -0.3, 1.1)
+ hidedecorations!(ax)
+ fig
+end
+
+function testimage_temp()
+ fig = Figure();
+ ax = Axis(fig[1, 1]);
+
+ ternarycontourf!(
+ ax,
+ a1,
+ a2,
+ a3,
+ mus;
+ levels = 10,
+ linewidth = 4,
+ color = nothing,
+ colormap = reverse(Makie.ColorSchemes.Spectral),
+ pad_data = true,
+ )
+
+ ternaryscatter!(
+ ax,
+ a1,
+ a2,
+ a3;
+ color = :black,
+ marker = :circle,
+ markersize = 15,
+ )
+
+ ternaryscatter!(
+ ax,
+ a1,
+ a2,
+ a3;
+ color = [get(reverse(Makie.ColorSchemes.Spectral), w, extrema(mus)) for w in mus],
+ marker = :circle,
+ markersize = 10,
+ )
+
+ ternaryaxis!(ax);
+
+ xlims!(ax, -0.2, 1.2)
+ ylims!(ax, -0.3, 1.1)
+ hidedecorations!(ax)
+ fig
+
+end
+
+@test_reference "../figs/axis.png" testimage_axis()
+@test_reference "../figs/lines.png" testimage_lines()
+@test_reference "../figs/scatter.png" testimage_scatter()
+@test_reference "../figs/contour.png" testimage_contour()
+@test_reference "../figs/contourfill.png" testimage_contourf()
+@test_reference "../figs/temp.png" testimage_temp()
diff --git a/test/runtests.jl b/test/runtests.jl
new file mode 100644
index 0000000..35169b6
--- /dev/null
+++ b/test/runtests.jl
@@ -0,0 +1,9 @@
+using SafeTestsets
+
+@safetestset "Aqua" begin
+ include("aqua.jl")
+end
+
+@safetestset "ReferenceTests" begin
+ include("referencetests.jl")
+end
\ No newline at end of file
diff --git a/test/scatter.jl b/test/scatter.jl
deleted file mode 100644
index ab8f084..0000000
--- a/test/scatter.jl
+++ /dev/null
@@ -1,33 +0,0 @@
-using Revise
-using CairoMakie
-using ColorSchemes
-using TernaryDiagrams
-using JLD2
-const td = TernaryDiagrams
-
-
-a1 = load("test/data.jld2", "a1")[1:20]
-a2 = load("test/data.jld2", "a2")[1:20]
-a3 = load("test/data.jld2", "a3")[1:20]
-ws = rand(20)
-
-fig = Figure();
-ax = Axis(fig[1, 1]);
-
-ternaryaxis!(ax);
-ternaryscatter!(
- ax,
- a1,
- a2,
- a3;
- color = [get(ColorSchemes.Spectral, w, extrema(ws)) for w in ws],
- marker = :circle,
- markersize = 20,
-)
-
-xlims!(ax, -0.2, 1.2)
-ylims!(ax, -0.3, 1.1)
-hidedecorations!(ax)
-fig
-
-Makie.FileIO.save("figs/scatter.svg", fig)