Skip to content

Commit b7e3722

Browse files
authored
Support labels (#42)
The aim is to get legends working with pharmacophore features. This requires overloading one function in Makie itself, so this defines an extension module. To make this easy, require Julia 1.10 as the new minimum version.
1 parent b789cb7 commit b7e3722

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

.github/workflows/CI.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
version:
21-
- '1.7'
22-
- 'nightly'
21+
- '1.10'
22+
- '1'
2323
os:
2424
- ubuntu-latest
2525
arch:

Project.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "GaussianMixtureAlignment"
22
uuid = "f2431ed1-b9c2-4fdb-af1b-a74d6c93b3b3"
33
authors = ["Tom McGrath <[email protected]> and contributors"]
4-
version = "0.1.9"
4+
version = "0.1.10"
55

66
[deps]
77
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
@@ -20,13 +20,20 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df"
2020
Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
2121
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
2222

23+
[weakdeps]
24+
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
25+
26+
[extensions]
27+
GaussianMixtureAlignmentMakieExt = "Makie"
28+
2329
[compat]
2430
CoordinateTransformations = "0.6"
2531
Distances = "0.10"
2632
Colors = "0.12"
2733
GenericLinearAlgebra = "0.3"
2834
GeometryBasics = "0.4"
2935
Hungarian = "0.7"
36+
Makie = "0.21"
3037
MakieCore = "0.6, 0.7, 0.8"
3138
MutableConvexHulls = "0.2"
3239
NearestNeighbors = "0.4.1"
@@ -35,7 +42,7 @@ PairedLinkedLists = "0.2"
3542
Requires = "1.3"
3643
Rotations = "1.4"
3744
StaticArrays = "1.5"
38-
julia = "1.7"
45+
julia = "1.10"
3946

4047
[extras]
4148
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module GaussianMixtureAlignmentMakieExt
2+
3+
using GaussianMixtureAlignment
4+
using Makie
5+
6+
# Needed to get legends working, see https://github.com/MakieOrg/Makie.jl/issues/1148
7+
Makie.get_plots(p::GaussianMixtureAlignment.GMMDisplay) = p.plots
8+
9+
end

src/draw.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ function plot!(gd::GaussianDisplay{<:NTuple{<:Any, <:AbstractIsotropicGaussian}}
6565
gauss = [gd[i][] for i=1:length(gd)]
6666
disp = gd[:display][]
6767
color = gd[:color][]
68+
label = gd[:label][]
6869
plotfun = disp == :wire ? wire_sphere! : ( disp == :solid ? solid_sphere! : throw(ArgumentError("Unrecognized display option: `$disp`")))
6970
for g in gauss
70-
plotfun(gd, g.μ, g.σ; color=color)
71+
plotfun(gd, g.μ, g.σ; color=color, label)
7172
end
7273
return gd
7374
end
@@ -77,6 +78,7 @@ end
7778
display = :wire,
7879
palette = DEFAULT_COLORS,
7980
color = nothing,
81+
label = "",
8082
)
8183
end
8284

@@ -86,9 +88,10 @@ function plot!(gd::GMMDisplay{<:NTuple{<:Any,<:AbstractIsotropicGMM}})
8688
disp = gd[:display][]
8789
color = gd[:color][]
8890
palette = gd[:palette][]
91+
label = gd[:label][]
8992
for (i,gmm) in enumerate(gmms)
9093
col = isnothing(color) ? palette[(i-1) % len + 1] : color
91-
gaussiandisplay!(gd, gmm.gaussians...; display=disp, color=col)
94+
gaussiandisplay!(gd, gmm.gaussians...; display=disp, color=col, label)
9295
end
9396
return gd
9497
end
@@ -106,7 +109,7 @@ function plot!(gd::GMMDisplay{<:NTuple{<:Any,<:AbstractIsotropicMultiGMM{N,T,K}}
106109
for (i,k) in enumerate(allkeys)
107110
col = isnothing(color) ? palette[(i-1) % len + 1] : color
108111
for mgmm in mgmms
109-
haskey(mgmm.gmms, k) && gmmdisplay!(gd, mgmm.gmms[k]; display=disp, color=col, palette=palette)
112+
haskey(mgmm.gmms, k) && gmmdisplay!(gd, mgmm.gmms[k]; display=disp, color=col, palette=palette, label=string(k))
110113
end
111114
end
112115
return gd

test/draw.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ using Test
2020
:positive => IsotropicGMM([ch_g]),
2121
:steric => IsotropicGMM(s_gs)
2222
))
23-
gmmdisplay(gmm)
23+
gmmdisplay(mgmmx)
2424
end

0 commit comments

Comments
 (0)