Merge pull request #1815 from daschw/heatmap

allow heatmap of nx1 or 1xn matrices
This commit is contained in:
Daniel Schwabeneder 2018-10-30 11:54:57 +01:00 committed by GitHub
commit 11c1a23dfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -614,7 +614,7 @@ function _update_min_padding!(sp::Subplot{GRBackend})
rightpad += 4mm rightpad += 4mm
else else
leftpad += 4mm leftpad += 4mm
end end
end end
if sp[:colorbar_title] != "" if sp[:colorbar_title] != ""
rightpad += 4mm rightpad += 4mm
@ -671,7 +671,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
outside_ticks = true outside_ticks = true
for ax in (sp[:xaxis], sp[:yaxis]) for ax in (sp[:xaxis], sp[:yaxis])
v = series[ax[:letter]] v = series[ax[:letter]]
if diff(collect(extrema(diff(v))))[1] > 1e-6*std(v) if length(v) > 1 && diff(collect(extrema(diff(v))))[1] > 1e-6*std(v)
@warn("GR: heatmap only supported with equally spaced data.") @warn("GR: heatmap only supported with equally spaced data.")
end end
end end

View File

@ -357,6 +357,7 @@ const _scale_base = Dict{Symbol, Real}(
) )
function _heatmap_edges(v::AVec) function _heatmap_edges(v::AVec)
length(v) == 1 && return v[1] .+ [-0.5, 0.5]
vmin, vmax = ignorenan_extrema(v) vmin, vmax = ignorenan_extrema(v)
extra_min = (v[2] - v[1]) / 2 extra_min = (v[2] - v[1]) / 2
extra_max = (v[end] - v[end - 1]) / 2 extra_max = (v[end] - v[end - 1]) / 2