Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
🐛 🎉 recipes fixes
Browse files Browse the repository at this point in the history
Closes #6
Closes #7
  • Loading branch information
tpoisot committed Nov 13, 2019
1 parent 6b2bdf6 commit 6bf8e7e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/recipes/recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
seriestype --> :heatmap
@assert eltype(layer) <: Number
if get(plotattributes, :seriestype, :heatmap) == :heatmap
x --> longitudes(layer)
y --> latitudes(layer)
z --> layer.grid
longitudes(layer), latitudes(layer), layer.grid
elseif get(plotattributes, :seriestype, :histogram) in [:histogram, :density]
filter(!isnan, layer.grid)
end
end

@recipe function plot(l1::T, l2::T) where {T <: SimpleSDMLayer}
seriestype --> :scatter
@assert eltype(l1) <: Number
@assert eltype(l2) <: Number
@assert size(l1) == size(l2)
@assert l1.top == l2.top
@assert l1.left == l2.left
@assert l1.bottom == l2.bottom
@assert l1.right == l2.right
valid_i =filter(i -> !(isnan(l1[i])|isnan(l2[i])), eachindex(l1.grid))
l1.grid[valid_i], l2.grid[valid_i]
if get(plotattributes, :seriestype, :scatter) in [:scatter, :histogram2d]
@assert eltype(l1) <: Number
@assert eltype(l2) <: Number
@assert size(l1) == size(l2)
@assert l1.top == l2.top
@assert l1.left == l2.left
@assert l1.bottom == l2.bottom
@assert l1.right == l2.right
valid_i =filter(i -> !(isnan(l1[i])|isnan(l2[i])), eachindex(l1.grid))
l1.grid[valid_i], l2.grid[valid_i]
end
end
Binary file modified test/gallery/heatmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/gallery/heatmap_scaledown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/gallery/scatter-2d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions test/plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ xaxis!("Temperature")
yaxis!("Precipitation")
savefig(joinpath("gallery", "scatter.png"))

histogram2d(temperature, precipitation, leg=false)
xaxis!("Temperature")
yaxis!("Precipitation")
savefig(joinpath("gallery", "scatter-2d.png"))

end

0 comments on commit 6bf8e7e

Please sign in to comment.