-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use concrete type instead of abstract Point2 #23
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "TernaryDiagrams" | ||
uuid = "54198458-1476-45ac-9e44-88a4201bfea6" | ||
authors = ["St. Elmo Wilken <[email protected]> and contributors"] | ||
version = "0.1.2" | ||
version = "0.1.3" | ||
|
||
[deps] | ||
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4" | ||
|
@@ -12,10 +12,11 @@ VoronoiDelaunay = "72f80fcb-8c52-57d9-aff0-40c1a3526986" | |
|
||
[compat] | ||
Aqua = "0.8" | ||
CairoMakie = "0.11, 0.12" | ||
ColorSchemes = "3" | ||
DocStringExtensions = "0.9" | ||
GeometricalPredicates = "0.4" | ||
GLMakie = "0.9, 0.10" | ||
GeometricalPredicates = "0.4" | ||
JLD2 = "0.5" | ||
Makie = "0.20, 0.21" | ||
ReferenceTests = "0.10" | ||
|
@@ -26,11 +27,12 @@ julia = "1" | |
|
||
[extras] | ||
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" | ||
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" | ||
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 = ["Aqua", "GLMakie", "JLD2", "ReferenceTests", "SafeTestsets", "Test"] | ||
test = ["Aqua", "CairoMakie", "GLMakie", "JLD2", "ReferenceTests", "SafeTestsets", "Test"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#This testset checks that reported issues have been resolved; prevents regressions. | ||
|
||
#https://github.com/stelmo/TernaryDiagrams.jl/issues/22 | ||
using CairoMakie | ||
using TernaryDiagrams | ||
@test_nowarn begin | ||
fig = Figure() | ||
ax = Axis(fig[1, 1]) | ||
ternaryaxis!(ax) | ||
ternaryscatter!(ax, [0.2, 0.1], [0.2, 0.6], [0.6, 0.3]) | ||
fig | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using GLMakie | ||
#using ColorSchemes | ||
using TernaryDiagrams | ||
using JLD2 | ||
using ReferenceTests | ||
|
@@ -10,42 +9,56 @@ a2 = a2[1:20] | |
a3 = a3[1:20] | ||
mus = mus[1:20] | ||
|
||
#Somehow fig seems to get converted in AbstractArray{<:Colorant} of different sizes, depending on | ||
#what display is used; the function below is a workaround through file saving/loading. Not | ||
#elegant, but it works. | ||
function save_load_remove(fig) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I asked on Slack and one can use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but at least when I am testing it locally, I get the wrong size of matrix out. Doing:
I would have expected an array of 1800 x 1200 pixels, but I am getting a Furthermore, what I am getting back is dependent on what display/monitor I am having the figure open on! I have two monitors: monitor 1 gives the above. When I move the same figure and run That kind of made me move in the direction of a workaround... Is there a direct and robust way of doing this correctly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm let me ask again on Slack if there is a standard way to do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But anyway that's off topic from this MR. Let's just get this merged and we can apply an eventual better solution in a separate MR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Solution seems to be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a new commit; needed some more tweaking, but I think this version is cleaner than before. |
||
n = "tmp.png" | ||
save(n, fig, size = (900, 600), px_per_unit = 2) | ||
arr = load(n) | ||
rm(n) | ||
return arr | ||
end | ||
|
||
function testimage_axis() | ||
fig = Figure(); | ||
ax = Axis(fig[1, 1]); | ||
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 | ||
|
||
arr = save_load_remove(fig) | ||
return arr | ||
end | ||
|
||
function testimage_lines() | ||
fig = Figure(); | ||
ax = Axis(fig[1, 1]); | ||
fig = Figure() | ||
ax = Axis(fig[1, 1]) | ||
|
||
ternaryaxis!(ax); | ||
ternaryaxis!(ax) | ||
ternarylines!(ax, a1, a2, a3; color = :blue) | ||
|
||
xlims!(ax, -0.2, 1.2) | ||
ylims!(ax, -0.3, 1.1) | ||
hidedecorations!(ax) | ||
fig | ||
|
||
arr = save_load_remove(fig) | ||
return arr | ||
end | ||
|
||
function testimage_scatter() | ||
fig = Figure(); | ||
ax = Axis(fig[1, 1]); | ||
fig = Figure() | ||
ax = Axis(fig[1, 1]) | ||
|
||
ternaryaxis!(ax); | ||
ternaryaxis!(ax) | ||
ternaryscatter!( | ||
ax, | ||
a1, | ||
|
@@ -59,12 +72,14 @@ function testimage_scatter() | |
xlims!(ax, -0.2, 1.2) | ||
ylims!(ax, -0.3, 1.1) | ||
hidedecorations!(ax) | ||
fig | ||
|
||
arr = save_load_remove(fig) | ||
return arr | ||
end | ||
|
||
function testimage_contour() | ||
fig = Figure(); | ||
ax = Axis(fig[1, 1]); | ||
fig = Figure() | ||
ax = Axis(fig[1, 1]) | ||
|
||
ternarycontour!( | ||
ax, | ||
|
@@ -79,28 +94,32 @@ function testimage_contour() | |
pad_data = true, | ||
) | ||
|
||
ternaryaxis!(ax); | ||
ternaryaxis!(ax) | ||
|
||
xlims!(ax, -0.2, 1.2) | ||
ylims!(ax, -0.3, 1.1) | ||
hidedecorations!(ax) | ||
fig | ||
|
||
arr = save_load_remove(fig) | ||
return arr | ||
end | ||
|
||
function testimage_contourf() | ||
fig = Figure(); | ||
ax = Axis(fig[1, 1]); | ||
fig = Figure() | ||
ax = Axis(fig[1, 1]) | ||
ternarycontourf!(ax, a1, a2, a3, mus; levels = 10) | ||
ternaryaxis!(ax); | ||
ternaryaxis!(ax) | ||
xlims!(ax, -0.2, 1.2) | ||
ylims!(ax, -0.3, 1.1) | ||
hidedecorations!(ax) | ||
fig | ||
|
||
arr = save_load_remove(fig) | ||
return arr | ||
end | ||
|
||
function testimage_temp() | ||
fig = Figure(); | ||
ax = Axis(fig[1, 1]); | ||
fig = Figure(size = (900, 600), px_per_unit = 2) | ||
ax = Axis(fig[1, 1]) | ||
|
||
ternarycontourf!( | ||
ax, | ||
|
@@ -135,13 +154,14 @@ function testimage_temp() | |
markersize = 10, | ||
) | ||
|
||
ternaryaxis!(ax); | ||
ternaryaxis!(ax) | ||
|
||
xlims!(ax, -0.2, 1.2) | ||
ylims!(ax, -0.3, 1.1) | ||
hidedecorations!(ax) | ||
fig | ||
|
||
arr = save_load_remove(fig) | ||
return arr | ||
end | ||
|
||
@test_reference "../figs/axis.png" testimage_axis() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not create a new file specific to issues, it might be better to append it to the reference tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to have only tests that compare produced plots/images against reference images in the referencetests.jl file to keep the different types of tests separate, but I would of course be fine to move them if you insist :)