From 6f36d0998fc61692e22b08e2a0d84b1397e9c2f0 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 16 Jul 2020 20:17:02 +0200 Subject: [PATCH 1/2] fix wrong image limits in pyplot (fix #2864) --- src/backends/pyplot.jl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 2c28bbee..8a5b81ca 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -729,7 +729,10 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) if st == :image # @show typeof(z) - xmin, xmax = ignorenan_extrema(series[:x]); ymin, ymax = ignorenan_extrema(series[:y]) + xmin, xmax = ignorenan_extrema(series[:x]) + ymin, ymax = ignorenan_extrema(series[:y]) + dx = (xmax - xmin) / (length(series[:x]) - 1) / 2 + dy = (ymax - ymin) / (length(series[:y]) - 1) / 2 img = Array(transpose_z(series, z.surf)) z = if eltype(img) <: Colors.AbstractGray float(img) @@ -743,7 +746,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) cmap = py_colormap(cgrad(plot_color([:black, :white]))), vmin = 0.0, vmax = 1.0, - extent = (xmin-0.5, xmax+0.5, ymax+0.5, ymin-0.5) + extent = (xmin - dx, xmax + dx, ymax + dy, ymin - dy) ) push!(handles, handle) From f9f6e0ff57d6e93b67e248749654ef02b29638f4 Mon Sep 17 00:00:00 2001 From: Simon Christ Date: Thu, 16 Jul 2020 21:25:46 +0200 Subject: [PATCH 2/2] remove show comments --- src/backends/pyplot.jl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 8a5b81ca..7eec026c 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -276,7 +276,6 @@ end function py_bbox_axis(ax, letter) ticks = py_bbox_ticks(ax, letter) labels = py_bbox_axislabel(ax, letter) - # letter == "x" && @show ticks labels ticks+labels ticks + labels end @@ -728,7 +727,6 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) end if st == :image - # @show typeof(z) xmin, xmax = ignorenan_extrema(series[:x]) ymin, ymax = ignorenan_extrema(series[:y]) dx = (xmax - xmin) / (length(series[:x]) - 1) / 2