Skip to content

Commit

Permalink
Document PlotRecipes, fix ordering of stepped line plots, update to v…
Browse files Browse the repository at this point in the history
…0.14.3
  • Loading branch information
Stuart Daines committed May 2, 2022
1 parent 90e664b commit ef5cba5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PALEOmodel"
uuid = "bf7b4fbe-ccb1-42c5-83c2-e6e9378b660c"
authors = ["Stuart Daines <[email protected]>"]
version = "0.14.2"
version = "0.14.3"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
9 changes: 7 additions & 2 deletions docs/src/PALEOmodel.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,19 @@ add_record!

## Plot output

Plot recipes for `PALEOboxes.FieldArray` TODO

```@meta
CurrentModule = PALEOmodel
```
```@docs
RecipesBase.apply_recipe(::Dict{Symbol, Any}, fa::FieldArray)
RecipesBase.apply_recipe(::Dict{Symbol, Any}, output::AbstractOutputWriter, vars::Union{AbstractString, Vector{<:AbstractString}}, selectargs::NamedTuple)
RecipesBase.apply_recipe(::Dict{Symbol, Any}, outputs::Vector{<:AbstractOutputWriter}, vars::Union{AbstractString, Vector{<:AbstractString}}, selectargs::NamedTuple)
RecipesBase.apply_recipe(::Dict{Symbol, Any}, fr::FieldRecord, selectargs::NamedTuple)
RecipesBase.apply_recipe(::Dict{Symbol, Any}, fas::Vector{<:FieldArray})
PlotPager
Plot.test_heatmap_edges
```
## Analyze reaction network
```@meta
Expand Down
4 changes: 0 additions & 4 deletions src/PALEOmodel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import SparsityTracing
PB.value_ad(x::SparsityTracing.ADval) = SparsityTracing.value(x)
PB.value_ad(x::ForwardDiff.Dual) = ForwardDiff.value(x)

"base type for plot commands"
abstract type AbstractPlot
end

"base type for OutputWriters"
abstract type AbstractOutputWriter
end
Expand Down
36 changes: 17 additions & 19 deletions src/PlotRecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Optional `kwargs` provides keyword arguments supplied to `plot`
julia> pp(:newpage) # flush any partial screen and start new page (NB: always add this at end of a sequence!)
# Commands
- `pp(p::AbstractPlot)`: accumulate plot p
- `pp(p)`: accumulate plot p
- `pp(:skip)`: leave a blank panel
- `pp(:newpage)`: fill with blank panels and start new page
- `pp(p1, p2, ...)`: multiple plots/commands in one call
Expand Down Expand Up @@ -115,11 +115,9 @@ end
###############################

"""
@recipe function f(output::AbstractOutputWriter, vars::Union{AbstractString, Vector}, selectargs::NamedTuple=NamedTuple())
plot(output::AbstractOutputWriter, vars::Union{AbstractString, Vector{<:AbstractString}}, selectargs::NamedTuple=NamedTuple())
Plot recipe that calls `PB.get_field(output, var)`
and passes on to `@recipe function f(fr::FieldRecord, selectargs::NamedTuple)`
Plot recipe that calls `PB.get_field(output, var)`, and passes on to `plot(fr::FieldRecord, selectargs)`
Additional features:
- if `vars` is a Vector, create a plot series for each element.
Expand Down Expand Up @@ -152,10 +150,10 @@ RecipesBase.@recipe function f(
end

"""
@recipe function f(outputs::Vector{<:AbstractOutputWriter}, vars::Union{AbstractString, Vector}, selectargs::NamedTuple=NamedTuple())
plot(outputs::Vector{<:AbstractOutputWriter}, vars::Union{AbstractString, Vector{<:AbstractString}}, selectargs::NamedTuple=NamedTuple())
Pass through (ie "broadcast") each element of `output` to
`@recipe function f(output::AbstractOutputWriter, vars::Union{AbstractString, Vector}, selectargs::NamedTuple=NamedTuple())`,
Pass through (ie "broadcast") each element `output` of `outputs` to
`plot(output::AbstractOutputWriter, vars, selectargs)`,
adding a `labelprefix` (index in `outputs` Vector) to identify each plot series produced.
"""
RecipesBase.@recipe function f(
Expand All @@ -175,9 +173,9 @@ end


"""
@recipe function f(fr::FieldRecord, selectargs::NamedTuple)
plot(fr::FieldRecord, selectargs::NamedTuple)
Plot recipe that calls `get_array(fr; selectargs...)` and passes on to `@recipe function f(fa::FieldArray)`.
Plot recipe that calls `get_array(fr; selectargs...)` and passes on to `plot(fa::FieldArray)`.
Vector-valued fields in `selectargs` are broadcasted (generating a separate plot series for each combination)
"""
Expand All @@ -195,7 +193,7 @@ end


"""
@recipe function f(fa::FieldArray; kwargs...)
plot(fa::FieldArray; kwargs...)
Plot recipe that plots `fa`. If `fa` has a single dimension, this is suitable for a line-like plot,
if two dimensions, a heatmap.
Expand Down Expand Up @@ -350,9 +348,9 @@ RecipesBase.@recipe function f(
end

"""
@recipe function f(fas::Vector{<:FieldArray}; labelprefix="")
plot(fas::Vector{<:FieldArray}; labelprefix="")
Pass through (ie "broadcast") each element of `fas` to `@recipe function f(fa::FieldArray)`,
Pass through (ie "broadcast") each element of `fas` to `plot(fa::FieldArray)`,
generating one plot series for each. Adds Vector index to `labelprefix`.
"""
RecipesBase.@recipe function f(
Expand All @@ -378,17 +376,17 @@ function create_stepped(z1, z2, data)
z = Float64[]
d = Float64[]

if z1[end] < z1[begin]
zlower, zupper = z1, z2
if (z1[end] > z1[begin]) == (z2[begin] > z1[begin])
zfirst, zsecond = z1, z2
else
zlower, zupper = z2, z1
zfirst, zsecond = z2, z1
end

for (dval, zl, zu) in zip(data, zlower, zupper)
push!(z, zu)
push!(d, dval)
for (dval, zl, zu) in zip(data, zfirst, zsecond)
push!(z, zl)
push!(d, dval)
push!(z, zu)
push!(d, dval)
end
return z, d
end
Expand Down

2 comments on commit ef5cba5

@sjdaines
Copy link
Member

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/59528

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.14.3 -m "<description of version>" ef5cba5229ed54dfe9872e8d934470354721c864
git push origin v0.14.3

Please sign in to comment.