Merge pull request #1477 from daschw/heatmap-recipe
RFC: WIP: Heatmap recipe
This commit is contained in:
commit
e305b973b2
@ -183,6 +183,7 @@ include("output.jl")
|
|||||||
@shorthands histogram2d
|
@shorthands histogram2d
|
||||||
@shorthands density
|
@shorthands density
|
||||||
@shorthands heatmap
|
@shorthands heatmap
|
||||||
|
@shorthands plots_heatmap
|
||||||
@shorthands hexbin
|
@shorthands hexbin
|
||||||
@shorthands sticks
|
@shorthands sticks
|
||||||
@shorthands hline
|
@shorthands hline
|
||||||
|
|||||||
@ -669,6 +669,8 @@ function plotly_series_shapes(plt::Plot, series::Series)
|
|||||||
d_outs[i] = d_out
|
d_outs[i] = d_out
|
||||||
end
|
end
|
||||||
if series[:fill_z] != nothing
|
if series[:fill_z] != nothing
|
||||||
|
push!(d_outs, plotly_colorbar_hack(series, base_d, :fill))
|
||||||
|
elseif series[:line_z] != nothing
|
||||||
push!(d_outs, plotly_colorbar_hack(series, base_d, :line))
|
push!(d_outs, plotly_colorbar_hack(series, base_d, :line))
|
||||||
end
|
end
|
||||||
d_outs
|
d_outs
|
||||||
|
|||||||
@ -389,6 +389,33 @@ end
|
|||||||
end
|
end
|
||||||
@deps bar shape
|
@deps bar shape
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Plots Heatmap
|
||||||
|
@recipe function f(::Type{Val{:plots_heatmap}}, x, y, z)
|
||||||
|
xe, ye = heatmap_edges(x), heatmap_edges(y)
|
||||||
|
m, n = size(z.surf)
|
||||||
|
x_pts, y_pts = fill(NaN, 6 * m * n), fill(NaN, 6 * m * n)
|
||||||
|
fz = zeros(m * n)
|
||||||
|
for i in 1:m # y
|
||||||
|
for j in 1:n # x
|
||||||
|
k = (j - 1) * m + i
|
||||||
|
inds = (6 * (k - 1) + 1):(6 * k - 1)
|
||||||
|
x_pts[inds] .= [xe[j], xe[j + 1], xe[j + 1], xe[j], xe[j]]
|
||||||
|
y_pts[inds] .= [ye[i], ye[i], ye[i + 1], ye[i + 1], ye[i]]
|
||||||
|
fz[k] = z.surf[i, j]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ensure_gradient!(plotattributes, :fillcolor, :fillalpha)
|
||||||
|
fill_z := fz
|
||||||
|
line_z := fz
|
||||||
|
x := x_pts
|
||||||
|
y := y_pts
|
||||||
|
z := nothing
|
||||||
|
seriestype := :shape
|
||||||
|
label := ""
|
||||||
|
()
|
||||||
|
end
|
||||||
|
@deps plots_heatmap shape
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
# Histograms
|
# Histograms
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
const FuncOrFuncs{F} = Union{F, Vector{F}, Matrix{F}}
|
const FuncOrFuncs{F} = Union{F, Vector{F}, Matrix{F}}
|
||||||
|
|
||||||
all3D(d::KW) = trueOrAllTrue(st -> st in (:contour, :contourf, :heatmap, :surface, :wireframe, :contour3d, :image), get(d, :seriestype, :none))
|
all3D(d::KW) = trueOrAllTrue(st -> st in (:contour, :contourf, :heatmap, :surface, :wireframe, :contour3d, :image, :plots_heatmap), get(d, :seriestype, :none))
|
||||||
|
|
||||||
# unknown
|
# unknown
|
||||||
convertToAnyVector(x, d::KW) = error("No user recipe defined for $(typeof(x))")
|
convertToAnyVector(x, d::KW) = error("No user recipe defined for $(typeof(x))")
|
||||||
|
|||||||
@ -643,17 +643,12 @@ end
|
|||||||
function get_fillcolor(series, i::Int = 1)
|
function get_fillcolor(series, i::Int = 1)
|
||||||
fc = series[:fillcolor]
|
fc = series[:fillcolor]
|
||||||
fz = series[:fill_z]
|
fz = series[:fill_z]
|
||||||
lz = series[:line_z]
|
if fz == nothing
|
||||||
if fz == nothing && lz == nothing
|
|
||||||
isa(fc, ColorGradient) ? fc : _cycle(fc, i)
|
isa(fc, ColorGradient) ? fc : _cycle(fc, i)
|
||||||
else
|
else
|
||||||
cmin, cmax = get_clims(series[:subplot])
|
cmin, cmax = get_clims(series[:subplot])
|
||||||
grad = isa(fc, ColorGradient) ? fc : cgrad()
|
grad = isa(fc, ColorGradient) ? fc : cgrad()
|
||||||
if fz != nothing
|
grad[clamp((_cycle(fz, i) - cmin) / (cmax - cmin), 0, 1)]
|
||||||
grad[clamp((_cycle(fz, i) - cmin) / (cmax - cmin), 0, 1)]
|
|
||||||
elseif lz != nothing
|
|
||||||
grad[clamp((_cycle(lz, i) - cmin) / (cmax - cmin), 0, 1)]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user