Skip to content

Conversation

@gustaphe
Copy link
Collaborator

Solves #71.

Accept unitful AbstractArrays and Vectors of unitful Vectors as the x axis to functions, leading to multiple series.

(Also more consistently abbreviate array types to save text width and increase legibility, and create a plot(u, f) recipe to go with the plot(f, u) recipe)


# Recipes for functions
@recipe function f(f::Function, x::T) where T <: AVec{<:Union{Missing,<:Quantity}}
@recipe function f(f::Function, x::T) where T <: AArr{<:UMQ}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Meaningful change

x, f.(x)
end
@recipe function f(x::T, f::Function) where T <: AVec{<:Union{Missing,<:Quantity}}
@recipe function f(x::T, f::Function) where T <: AArr{<:UMQ}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Meaningful change

Comment on lines +110 to +112
@recipe function f(u::Units, f::Function)
return f, u
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

A mirror of f(f, u)

Comment on lines +113 to +128
#=========================================================================
If x is an array of arrays of quantities, consider those different series.
No need to dive deeper than this, a plot of arrays of arrays of arrays is
not implemented in Plots.
=========================================================================#
@recipe function f(f::Function, x::AArrArrQ)
for s in x
@series begin
xunit := unit(first(first(x)))
f, s
end
end
end
@recipe function f(x::AArrArrQ, f::Function)
return f, x
end
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Array of array

@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2022

Codecov Report

Base: 88.80% // Head: 87.40% // Decreases project coverage by -1.39% ⚠️

Coverage data is based on head (d2a4b2a) compared to base (79b7ada).
Patch coverage: 41.17% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #78      +/-   ##
==========================================
- Coverage   88.80%   87.40%   -1.40%     
==========================================
  Files           1        1              
  Lines         125      135      +10     
==========================================
+ Hits          111      118       +7     
- Misses         14       17       +3     
Impacted Files Coverage Δ
src/UnitfulRecipes.jl 87.40% <41.17%> (-1.40%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants