Skip to content
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

Makie.jl extension #145

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ julia = "1"

[extensions]
MeasurementsJunoExt = "Juno"
MeasurementsMakieExt = "Makie"
MeasurementsRecipesBaseExt = "RecipesBase"
MeasurementsSpecialFunctionsExt = "SpecialFunctions"
MeasurementsUnitfulExt = "Unitful"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Juno = "e5e0dc1b-0480-54bc-9374-aad01c23163d"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't used, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not at the moment, ideally, i would like to add some tests, but i'm not familiar enough with the makie testing infraestructure

QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
Expand All @@ -38,6 +40,7 @@ test = ["Aqua", "QuadGK", "RecipesBase", "SpecialFunctions", "Statistics", "Test

[weakdeps]
Juno = "e5e0dc1b-0480-54bc-9374-aad01c23163d"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
49 changes: 49 additions & 0 deletions ext/MeasurementsMakieExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
### plot-recipes.jl
#
# Copyright (C) 2017 Mosè Giordano.
longemen3000 marked this conversation as resolved.
Show resolved Hide resolved
#
# Maintainer: Mosè Giordano <mose AT gnu DOT org>
# Keywords: uncertainty, error propagation, physics, plots
#
# This file is a part of Measurements.jl.
#
# License is MIT "Expat".
#
### Commentary:
#
# This file defines the recipes to plot Measurements vectors with Makie.jl package in 2D.
#
### Code:
module MeasurementsMakieExt

if isdefined(Base, :get_extension)
using Measurements: Measurement, value, uncertainty
using Makie: Makie, PointBased, Errorbars, Band
else
using ..Measurements: Measurement, value, uncertainty
using ..Makie: Makie, PointBased, Errorbars, Band
end
# PointBased plots
Makie.convert_arguments(P::PointBased, x::AbstractVector{<:Measurement}, y::AbstractVector{<:Measurement}) =
convert_arguments(P, value.(x), value.(y))
Makie.convert_arguments(P::PointBased, x::AbstractVector{<:Real}, y::AbstractVector{<:Measurement}) =
convert_arguments(P, x, value.(y))
Makie.convert_arguments(P::PointBased, x::AbstractVector{<:Measurement}, y::AbstractVector{<:Real}) =
convert_arguments(P, value.(x), y)

# errorbars
Makie.convert_arguments(P::Type{<:Errorbars}, x::AbstractVector{<:Measurement}, y::AbstractVector{<:Measurement}, e::AbstractVector{<:Measurement}) =
convert_arguments(P, value.(x), value.(y), uncertainty.(e))
Makie.convert_arguments(P::Type{<:Errorbars}, x::AbstractVector{<:Measurement}, y::AbstractVector{<:Real}) =
convert_arguments(P, value.(x), y, uncertainty.(x))
Makie.convert_arguments(P::Type{<:Errorbars}, x::AbstractVector{<:Real}, y::AbstractVector{<:Measurement}) =
convert_arguments(P, x, value.(y), uncertainty.(y))

# band
Makie.convert_arguments(P::Type{<:Band}, x::AbstractVector{<:Measurement}, y::AbstractVector{<:Measurement}) =
convert_arguments(P, value.(x), value.(y) - uncertainty.(y), value.(y) + uncertainty.(y))
Makie.convert_arguments(P::Type{<:Band}, x::AbstractVector{<:Real}, y::AbstractVector{<:Measurement}) =
convert_arguments(P, x, value.(y) - uncertainty.(y), value.(y) + uncertainty.(y))

end #module

longemen3000 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions src/Measurements.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ end
@require Unitful="1986cc42-f94f-5a68-af5c-568840ba703d" include("../ext/MeasurementsUnitfulExt.jl")
@require SpecialFunctions="276daf66-3868-5448-9aa4-cd146d93841b" include("../ext/MeasurementsSpecialFunctionsExt.jl")
@require Juno="e5e0dc1b-0480-54bc-9374-aad01c23163d" include("../ext/MeasurementsJunoExt.jl")
@require Makie="ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" include("../ext/MeasurementsMakieExt.jl")
longemen3000 marked this conversation as resolved.
Show resolved Hide resolved
end
end

Expand Down