diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f152389..7e71088 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -53,7 +53,6 @@ jobs: - uses: julia-actions/julia-docdeploy@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GKSwstype: "100" - run: | julia --project=docs -e ' using Documenter: DocMeta, doctest diff --git a/docs/src/images/clustered1.png b/docs/src/images/clustered1.png new file mode 100644 index 0000000..d605945 Binary files /dev/null and b/docs/src/images/clustered1.png differ diff --git a/docs/src/images/clustered2.png b/docs/src/images/clustered2.png new file mode 100644 index 0000000..11065ff Binary files /dev/null and b/docs/src/images/clustered2.png differ diff --git a/docs/src/images/clustered3.png b/docs/src/images/clustered3.png new file mode 100644 index 0000000..3281abd Binary files /dev/null and b/docs/src/images/clustered3.png differ diff --git a/docs/src/images/customsampling.png b/docs/src/images/customsampling.png new file mode 100644 index 0000000..b23a741 Binary files /dev/null and b/docs/src/images/customsampling.png differ diff --git a/docs/src/images/equallyspaced1.png b/docs/src/images/equallyspaced1.png new file mode 100644 index 0000000..4639a89 Binary files /dev/null and b/docs/src/images/equallyspaced1.png differ diff --git a/docs/src/images/equallyspaced2.png b/docs/src/images/equallyspaced2.png new file mode 100644 index 0000000..4639a89 Binary files /dev/null and b/docs/src/images/equallyspaced2.png differ diff --git a/docs/src/images/equallyspaced3.png b/docs/src/images/equallyspaced3.png new file mode 100644 index 0000000..5d08fac Binary files /dev/null and b/docs/src/images/equallyspaced3.png differ diff --git a/docs/src/images/quick_start.jl b/docs/src/images/quick_start.jl new file mode 100644 index 0000000..1c04190 --- /dev/null +++ b/docs/src/images/quick_start.jl @@ -0,0 +1,60 @@ +using EllipseSampling +using Plots; gr() +Plots.reset_defaults() +default(palette=:seaborn_colorblind6, msw=0, markeralpha=0.7, aspect_ratio=:equal, label=nothing, dpi=150, size=(450,300)) +Plots.scalefontsizes(0.75) + +function main() + # Equally Spaced Points + e=construct_ellipse(1.0, 0.5, 0.0, 2.0, 1.0) + points=generate_N_equally_spaced_points(9, e; start_point_shift=0.0) + p = scatter(points[1,:], points[2,:]) + savefig(p, joinpath("docs", "src", "images", "equallyspaced1.png")) + + points=generate_N_equally_spaced_points(9, 1.0, 0.5, 0.0, 2.0, 1.0; start_point_shift=0.0) + p=scatter(points[1,:], points[2,:]) + savefig(p, joinpath("docs", "src", "images", "equallyspaced2.png")) + + ## Rotated Ellipses + e=construct_ellipse(1.0, 0.5, pi/3.0, 2.0, 1.0) + points=generate_N_equally_spaced_points(9, e; start_point_shift=0.0) + p=scatter(points[1,:], points[2,:]) + savefig(p, joinpath("docs", "src", "images", "equallyspaced3.png")) + + # Clustered Points + e=construct_ellipse(1.0, 0.1, 0.0, 2.0, 1.0) + points=generate_N_clustered_points(30, e; start_point_shift=0.0, sqrt_distortion=0.0) + p=scatter(points[1,:], points[2,:]) + savefig(p, joinpath("docs", "src", "images", "clustered1.png")) + + p=plot() + e=construct_ellipse(1.0, 0.1, 0.0, 2.0, 1.0) + for sqrt_distortion in 0.0:0.2:1.0 + points=generate_N_clustered_points(10, e; start_point_shift=0.0, sqrt_distortion=sqrt_distortion) + scatter!(p, points[1,:], points[2,:], label=string("sqrt_distortion=",sqrt_distortion)) + end + savefig(p, joinpath("docs", "src", "images", "clustered2.png")) + + p=plot(palette=:Paired_6) + e=construct_ellipse(1.0, 1.0, 0.0, 2.0, 1.0) + for sqrt_distortion in 0.0:0.5:1.0 + points=generate_N_clustered_points(10, e; start_point_shift=0.0, sqrt_distortion=sqrt_distortion) + scatter!(p, points[1,:], points[2,:], label=string("sqrt_distortion=",sqrt_distortion), + markersize=7-sqrt_distortion*4, markeralpha=0.8) + end + savefig(p, joinpath("docs", "src", "images", "clustered3.png")) + + # Custom Sampling Method + e=construct_ellipse(1.0, 0.5, 0.0, 2.0, 1.0) + N = 100 + samples = rand(N) + + # wrap e in Ref so that the function correctly broadcasts across samples + points = generate_perimeter_point.(samples, Ref(e)) + points = reduce(hcat, points) + + p=scatter(points[1,:], points[2,:]) + savefig(p, joinpath("docs", "src", "images", "customsampling.png")) +end + +main() \ No newline at end of file diff --git a/docs/src/quick_start.md b/docs/src/quick_start.md index cf68bbf..f0858eb 100644 --- a/docs/src/quick_start.md +++ b/docs/src/quick_start.md @@ -1,108 +1,91 @@ -```@setup quick_start -using EllipseSampling -using Pkg; Pkg.add("Plots") -using Plots; gr() -Plots.reset_defaults() -default(palette=:seaborn_colorblind6, msw=0, markeralpha=0.7, aspect_ratio=:equal, label=nothing) -``` # Quick Start +The following plots require these lines to be run first: + +```julia +using EllipseSampling, Plots; gr() +default(palette=:seaborn_colorblind6, msw=0, markeralpha=0.7, + aspect_ratio=:equal, label=nothing, dpi=150, size=(450,300)) +Plots.scalefontsizes(0.75) +``` + ## Equally Spaced Points To generate 9 equally spaced points on an ellipse, with x radius of 1.0 and y radius of 0.5, no rotation and a centre of ``x,y = [2,1]`` we use: -```example quick_start -using EllipseSampling, Plots - +```julia e=construct_ellipse(1.0, 0.5, 0.0, 2.0, 1.0) points=generate_N_equally_spaced_points(9, e; start_point_shift=0.0) scatter(points[1,:], points[2,:]) -savefig("equalspacing1.svg"); nothing # hide ``` -![](equalspacing1.svg) +![](images/equallyspaced1.png) Or alternatively: -```example quick_start -using EllipseSampling, Plots - +```julia points=generate_N_equally_spaced_points(9, 1.0, 0.5, 0.0, 2.0, 1.0; start_point_shift=0.0) scatter(points[1,:], points[2,:]) -savefig("equalspacing2.svg"); nothing # hide ``` -![](equalspacing2.svg) +![](images/equallyspaced2.png) ### Rotated Ellipses -If instead our ellipse has an anticlockwise rotation of ``\\frac{\\pi}{3}`` radians or 60 degrees then we modify that argument to [`construct_ellipse`](@ref). - -```example quick_start -using EllipseSampling, Plots +If instead our ellipse has an anticlockwise rotation of ``\frac{\pi}{3}`` radians or 60 degrees, we can modify that argument to [`construct_ellipse`](@ref). +```julia e=construct_ellipse(1.0, 0.5, pi/3.0, 2.0, 1.0) points=generate_N_equally_spaced_points(9, e; start_point_shift=0.0) scatter(points[1,:], points[2,:]) -savefig("equalspacing3.svg"); nothing # hide ``` - -![](equalspacing3.svg) +![](images/equallyspaced3.png) ## Clustered Points To more easily see the clustering effect we will increase the number of points generated and decrease the y radius. Note, the closer in magnitude the major and minor axis radii are, the weaker the clustering effect. To generate 30 clustered points on an ellipse, with x radius of 1.0 and y radius of 0.1, no rotation and a centre of ``x,y = [2,1]`` we use: -```example quick_start -using EllipseSampling, Plots - +```julia e=construct_ellipse(1.0, 0.1, 0.0, 2.0, 1.0) points=generate_N_clustered_points(30, e; start_point_shift=0.0, sqrt_distortion=0.0) scatter(points[1,:], points[2,:]) -savefig("clustering1.svg"); nothing # hide ``` -![](clustering1.svg) +![](images/clustered1.png) The clustering effect becomes weaker when we increase the parameter `sqrt_distortion` towards 1.0: -```example quick_start -using EllipseSampling, Plots - +```julia plot() e=construct_ellipse(1.0, 0.1, 0.0, 2.0, 1.0) for sqrt_distortion in 0.0:0.2:1.0 points=generate_N_clustered_points(10, e; start_point_shift=0.0, sqrt_distortion=sqrt_distortion) scatter!(points[1,:], points[2,:], label=string("sqrt_distortion=",sqrt_distortion)) end -savefig("clustering2.svg"); nothing # hide ``` -![](clustering2.svg) +![](images/clustered2.png) The clustering effect is completely gone if our ellipse is a circle: -```example quick_start -using EllipseSampling, Plots - -plot() +```julia +plot(palette=:Paired_6) e=construct_ellipse(1.0, 1.0, 0.0, 2.0, 1.0) for sqrt_distortion in 0.0:0.5:1.0 points=generate_N_clustered_points(10, e; start_point_shift=0.0, sqrt_distortion=sqrt_distortion) - scatter!(points[1,:], points[2,:], label=string("sqrt_distortion=",sqrt_distortion), - markersize=7-sqrt_distortion*3, markeralpha=0.5) + scatter!(p, points[1,:], points[2,:], label=string("sqrt_distortion=",sqrt_distortion), + markersize=7-sqrt_distortion*4, markeralpha=0.6) end -savefig("clustering3.svg"); nothing # hide ``` -![](clustering3.svg) + +![](images/clustered3.png) ## Custom Sampling Method -If we want to use a custom sampling method different to equal spacing and clustered methods then we can use [`generate_perimeter_point`](@ref) with any arbitrary distribution defined on \[0,1\]. For example, if we want to take 100 uniform random samples (uniform with respect to arc length) of our ellipse perimeter we would use: +If we want to use a custom sampling method different to equal spacing and clustered methods then we can use [`generate_perimeter_point`](@ref) with any arbitrary distribution defined on \[0,1\]. For example, if we want to take quick_start00 uniform random samples (uniform with respect to arc length) of our ellipse perimeter we would use: -```example quick_start -using EllipseSampling, Plots +```julia e=construct_ellipse(1.0, 0.5, 0.0, 2.0, 1.0) N = 100 samples = rand(N) @@ -112,7 +95,6 @@ points = generate_perimeter_point.(samples, Ref(e)) points = reduce(hcat, points) scatter(points[1,:], points[2,:]) -savefig("customsampling.svg"); nothing # hide ``` -![](customsampling.svg) \ No newline at end of file +![](images/customsampling.png) \ No newline at end of file