Merge pull request #2140 from yha/gr-heatmap-flip

Fix GR axis flip for heatmap and image plots
This commit is contained in:
Daniel Schwabeneder 2019-08-14 13:22:43 +03:00 committed by GitHub
commit e0a89c55ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1337,9 +1337,6 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
if !ispolar(sp) if !ispolar(sp)
xmin, xmax, ymin, ymax = xy_lims xmin, xmax, ymin, ymax = xy_lims
m, n = length(x), length(y) m, n = length(x), length(y)
xinds = sort(1:m, rev = xaxis[:flip])
yinds = sort(1:n, rev = yaxis[:flip])
z = reshape(reshape(z, m, n)[xinds, yinds], m*n)
GR.setspace(zmin, zmax, 0, 90) GR.setspace(zmin, zmax, 0, 90)
grad = isa(series[:fillcolor], ColorGradient) ? series[:fillcolor] : cgrad() grad = isa(series[:fillcolor], ColorGradient) ? series[:fillcolor] : cgrad()
colors = [plot_color(grad[clamp((zi-zmin) / (zmax-zmin), 0, 1)], series[:fillalpha]) for zi=z] colors = [plot_color(grad[clamp((zi-zmin) / (zmax-zmin), 0, 1)], series[:fillalpha]) for zi=z]
@ -1454,9 +1451,6 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
elseif st == :image elseif st == :image
z = transpose_z(series, series[:z].surf, true)' z = transpose_z(series, series[:z].surf, true)'
w, h = size(z) w, h = size(z)
xinds = sort(1:w, rev = xaxis[:flip])
yinds = sort(1:h, rev = yaxis[:flip])
z = z[xinds, yinds]
xmin, xmax = ignorenan_extrema(series[:x]); ymin, ymax = ignorenan_extrema(series[:y]) xmin, xmax = ignorenan_extrema(series[:x]); ymin, ymax = ignorenan_extrema(series[:y])
if eltype(z) <: Colors.AbstractGray if eltype(z) <: Colors.AbstractGray
grey = round.(UInt8, clamp.(float(z) * 255, 0, 255)) grey = round.(UInt8, clamp.(float(z) * 255, 0, 255))