Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.

Commit 42995ae

Browse files
committed
Add plot recipe for PointPattern
1 parent 5ed4e30 commit 42995ae

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ version = "0.1.0"
66
[deps]
77
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
88
GeoStatsBase = "323cb8eb-fbf6-51c0-afd0-f8fba70507b2"
9+
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
910
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
1011

1112
[compat]
1213
Distributions = "0.21"
1314
GeoStatsBase = "0.7"
15+
RecipesBase = "0.7"
1416
StaticArrays = "0.12"
1517
julia = "1"
1618

src/PointPatterns.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@ using GeoStatsBase
88

99
using Distributions: Uniform, Poisson, product_distribution
1010
using StaticArrays: SVector, MVector
11+
using RecipesBase
1112

1213
import GeoStatsBase: npoints, coordinates, coordinates!
1314

1415
include("pattern.jl")
1516
include("processes.jl")
1617

18+
# plot recipes
19+
include("plotrecipes/pattern.jl")
20+
1721
export
1822
# point pattern
1923
PointPattern,

src/plotrecipes/pattern.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# ------------------------------------------------------------------
2+
# Licensed under the ISC License. See LICENSE in the project root.
3+
# ------------------------------------------------------------------
4+
5+
@recipe function f(pp::PointPattern{T,N}) where {N,T}
6+
X = coordinates(pp)
7+
8+
seriestype --> :scatter
9+
markersize --> 2
10+
color --> :black
11+
legend --> false
12+
13+
if N == 1
14+
@series begin
15+
X[1,:], fill(0, npoints(pp))
16+
end
17+
elseif N == 2
18+
aspect_ratio --> :equal
19+
@series begin
20+
X[1,:], X[2,:]
21+
end
22+
elseif N == 3
23+
aspect_ratio --> :equal
24+
@series begin
25+
X[1,:], X[2,:], X[3,:]
26+
end
27+
else
28+
@error "cannot plot in more than 3 dimensions"
29+
end
30+
end

0 commit comments

Comments
 (0)