From f68f82e3f438b45938cf27c242cc0e5d336278fc Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Thu, 11 Aug 2016 16:20:43 -0400 Subject: [PATCH] gr: fix image and alpha; switch transpose_z to use permutedims --- src/backends/gr.jl | 24 ++++++++++++------------ src/utils.jl | 3 ++- test/runtests.jl | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 74b2c354..49e5cae8 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -199,14 +199,14 @@ function gr_polaraxes(rmin, rmax) GR.drawarc(-r, r, -r, r, 0, 359) end end - for alpha in 0:45:315 - a = alpha + 90 + for α in 0:45:315 + a = α + 90 sinf = sin(a * pi / 180) cosf = cos(a * pi / 180) GR.polyline([sinf, 0], [cosf, 0]) GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_HALF) x, y = GR.wctondc(1.1 * sinf, 1.1 * cosf) - GR.textext(x, y, string(alpha, "^o")) + GR.textext(x, y, string(α, "^o")) end GR.restorestate() end @@ -648,7 +648,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) # TODO: can we remove? gr_set_font(xaxis[:tickfont]) - GR.setcolormap(1000 + GR.COLORMAP_COOLWARM) + # GR.setcolormap(1000 + GR.COLORMAP_COOLWARM) for (idx, series) in enumerate(series_list(sp)) st = series[:seriestype] @@ -805,15 +805,15 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) a2 = round(Int, a1 + (slices[i] / total) * 360.0) GR.setfillcolorind(980 + (i-1) % 20) GR.fillarc(xmin, xmax, ymin, ymax, a1, a2) - alpha = 0.5 * (a1 + a2) - cosf = r * cos(alpha * pi / 180) - sinf = r * sin(alpha * pi / 180) + α = 0.5 * (a1 + a2) + cosf = r * cos(α * pi / 180) + sinf = r * sin(α * pi / 180) x[1] = xcenter + cosf y[1] = ycenter + sinf x[2] = x[1] + 0.1 * cosf y[2] = y[1] + 0.1 * sinf y[3] = y[2] - if 90 <= alpha < 270 + if 90 <= α < 270 x[3] = x[2] - 0.05 GR.settextalign(GR.TEXT_HALIGN_RIGHT, GR.TEXT_VALIGN_HALF) gr_text(x[3] - 0.01, y[3], string(labels[i])) @@ -849,15 +849,15 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) elseif st == :image img = series[:z].surf - w, h = size(img) - if eltype(img) <: Colors.AbstractGray - grey = round(UInt8, float(img) * 255) + h, w = size(img) + if eltype(z) <: Colors.AbstractGray + grey = round(UInt8, float(z) * 255) rgba = map(c -> UInt32( 0xff000000 + Int(c)<<16 + Int(c)<<8 + Int(c) ), grey) else rgba = map(c -> UInt32( round(Int, alpha(c) * 255) << 24 + round(Int, blue(c) * 255) << 16 + round(Int, green(c) * 255) << 8 + - round(Int, red(c) * 255) ), img) + round(Int, red(c) * 255) ), z) end GR.drawimage(xmin, xmax, ymax, ymin, w, h, rgba) end diff --git a/src/utils.jl b/src/utils.jl index 5bf8b37b..c997d482 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -445,7 +445,8 @@ end # for example: PyPlot sends rows to y, so transpose_on_match should be true function transpose_z(d, z, transpose_on_match::Bool = true) if d[:match_dimensions] == transpose_on_match - z' + # z' + permutedims(z, [2,1]) else z end diff --git a/test/runtests.jl b/test/runtests.jl index 92a491df..7eb315f2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -30,7 +30,7 @@ facts("GR") do @fact gr() --> Plots.GRBackend() @fact backend() --> Plots.GRBackend() - # @linux_only image_comparison_facts(:gr, skip=[], eps=img_eps) + # @static is_linux() && image_comparison_facts(:gr, skip=[], eps=img_eps) end facts("Plotly") do @@ -38,7 +38,7 @@ facts("Plotly") do @fact backend() --> Plots.PlotlyBackend() # # until png generation is reliable on OSX, just test on linux - # @linux_only image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], eps=img_eps) + # @static is_linux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], eps=img_eps) end