Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ version = "1.40.16"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Contour = "d38c429a-6771-53c6-b99e-75d170b6e991"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Dierckx = "39dd38d3-220a-591b-8e3c-4c3a8c710a94"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
Expand Down Expand Up @@ -58,6 +59,7 @@ UnitfulExt = "Unitful"
[compat]
Aqua = "0.8"
Contour = "0.5 - 0.6"
Dierckx = "0.5.4"
Downloads = "1"
FFMPEG = "0.4.1"
FixedPointNumbers = "0.6 - 0.8"
Expand Down
26 changes: 25 additions & 1 deletion src/pipeline.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# RecipesPipeline API

using Dierckx
## Warnings

function RecipesPipeline.warn_on_recipe_aliases!(
Expand Down Expand Up @@ -374,11 +374,35 @@ function RecipesPipeline.add_series!(plt::Plot, plotattributes)
plotattributes[letter1], plotattributes[letter2] =
plotattributes[letter2], plotattributes[letter1]
end
if plotattributes[:seriestype] === :heatmap
if haskey(plotattributes, :interpolate)
s = plotattributes[:interpolate]
x = collect(plotattributes[:x])
y = collect(plotattributes[:y])
z = reshape(collect(plotattributes[:z]),4,4)
finerx, finery, zinterp = cubic_interp_2d( x, y, z, s )
plotattributes[:x] = finerx
plotattributes[:y] = finery
plotattributes[:z] = Surface(zinterp)
plotattributes[:size] = (length(finerx), length(finery))
end
end
_expand_subplot_extrema(sp, plotattributes, plotattributes[:seriestype])
_update_series_attributes!(plotattributes, plt, sp)
return _add_the_series(plt, sp, plotattributes)
end

function cubic_interp_2d( x, y, data, s )
spl = Spline2D(y, x, data; kx=3, ky=3, s=0.0)
finerx = LinRange(x[1], x[end], s[1])
finery = LinRange(y[1], y[end], s[2])
data_interp = Array{Float64}(undef, s[2], s[1])
for (i,yint) ∈ enumerate(finery), (j,xint) ∈ enumerate(finerx)
data_interp[i,j] = evaluate(spl, yint, xint)
end
return finerx, finery, data_interp
end

# getting ready to add the series... last update to subplot from anything
# that might have been added during series recipes
function _prepare_subplot(plt::Plot{T}, plotattributes::AKW) where {T}
Expand Down
9 changes: 9 additions & 0 deletions test/test_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,13 @@ Plots.with(:gr) do
show(devnull, scatter(x, y))
# show(devnull, plot(x, y)) # currently unsupported
end

@testset "heatmap interpolation" begin
@test heatmap(
1:4,
1:4,
[1 2 3 4; 5 6 7 8; 9 10 11 12; 13 14 15 16];
interpolate = (10, 10),
)
end
end
Loading