Heatmap log scale fix
This commit is contained in:
parent
30af3c7f8a
commit
781fea7431
@ -718,6 +718,9 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
end
|
end
|
||||||
if st == :heatmap
|
if st == :heatmap
|
||||||
outside_ticks = true
|
outside_ticks = true
|
||||||
|
for ax in (sp[:xaxis], sp[:yaxis])
|
||||||
|
ax[:scale] != :identity && warn("GR: heatmap with $(ax[:scale]) scale not supported.")
|
||||||
|
end
|
||||||
x, y = heatmap_edges(series[:x], sp[:xaxis][:scale]), heatmap_edges(series[:y], sp[:yaxis][:scale])
|
x, y = heatmap_edges(series[:x], sp[:xaxis][:scale]), heatmap_edges(series[:y], sp[:yaxis][:scale])
|
||||||
xy_lims = x[1], x[end], y[1], y[end]
|
xy_lims = x[1], x[end], y[1], y[end]
|
||||||
expand_extrema!(sp[:xaxis], x)
|
expand_extrema!(sp[:xaxis], x)
|
||||||
|
|||||||
@ -587,6 +587,8 @@ function plotly_series(plt::Plot, series::Series)
|
|||||||
return plotly_series_segments(series, d_out, x, y, z)
|
return plotly_series_segments(series, d_out, x, y, z)
|
||||||
|
|
||||||
elseif st == :heatmap
|
elseif st == :heatmap
|
||||||
|
x = heatmap_edges(x, sp[:xaxis][:scale])
|
||||||
|
y = heatmap_edges(y, sp[:yaxis][:scale])
|
||||||
d_out[:type] = "heatmap"
|
d_out[:type] = "heatmap"
|
||||||
d_out[:x], d_out[:y], d_out[:z] = x, y, z
|
d_out[:x], d_out[:y], d_out[:z] = x, y, z
|
||||||
d_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
|
d_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha])
|
||||||
|
|||||||
14
src/utils.jl
14
src/utils.jl
@ -358,19 +358,17 @@ const _scale_base = Dict{Symbol, Real}(
|
|||||||
:ln => e,
|
:ln => e,
|
||||||
)
|
)
|
||||||
|
|
||||||
"create an (n+1) list of the outsides of heatmap rectangles"
|
function _heatmap_edges(v::AVec)
|
||||||
function heatmap_edges(v::AVec, scale::Symbol = :identity)
|
|
||||||
vmin, vmax = ignorenan_extrema(v)
|
vmin, vmax = ignorenan_extrema(v)
|
||||||
extra_min = extra_max = 0.5 * (vmax-vmin) / (length(v)-1)
|
extra_min = extra_max = 0.5 * (vmax-vmin) / (length(v)-1)
|
||||||
if scale in _logScales
|
|
||||||
vmin > 0 || error("The axis values must be positive for a $scale scale")
|
|
||||||
while vmin - extra_min <= 0
|
|
||||||
extra_min /= _scale_base[scale]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
vcat(vmin-extra_min, 0.5 * (v[1:end-1] + v[2:end]), vmax+extra_max)
|
vcat(vmin-extra_min, 0.5 * (v[1:end-1] + v[2:end]), vmax+extra_max)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
"create an (n+1) list of the outsides of heatmap rectangles"
|
||||||
|
function heatmap_edges(v::AVec, scale::Symbol = :identity)
|
||||||
|
f, invf = scalefunc(scale), invscalefunc(scale)
|
||||||
|
map(invf, _heatmap_edges(map(f,v)))
|
||||||
|
end
|
||||||
|
|
||||||
function calc_r_extrema(x, y)
|
function calc_r_extrema(x, y)
|
||||||
xmin, xmax = ignorenan_extrema(x)
|
xmin, xmax = ignorenan_extrema(x)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user