From 33327d39926c1716c4c55d20498ec326cdd9ce5c Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 18 Jun 2017 17:45:20 +0200 Subject: [PATCH 01/11] allow turning off the colorbar for heatmap, contour and surface --- src/backends/plotly.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 4f3c956c..b7520e23 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -479,6 +479,7 @@ function plotly_series(plt::Plot, series::Series) d_out[:type] = "heatmap" # d_out[:x], d_out[:y], d_out[:z] = series[:x], series[:y], transpose_z(series, series[:z].surf, false) d_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha]) + d_out[:showscale] = sp[:legend] != :none elseif st == :contour d_out[:type] = "contour" @@ -487,6 +488,7 @@ function plotly_series(plt::Plot, series::Series) d_out[:ncontours] = series[:levels] d_out[:contours] = KW(:coloring => series[:fillrange] != nothing ? "fill" : "lines") d_out[:colorscale] = plotly_colorscale(series[:linecolor], series[:linealpha]) + d_out[:showscale] = sp[:legend] != :none elseif st in (:surface, :wireframe) d_out[:type] = "surface" @@ -504,6 +506,7 @@ function plotly_series(plt::Plot, series::Series) if series[:fill_z] != nothing d_out[:surfacecolor] = plotly_surface_data(series, series[:fill_z]) end + d_out[:showscale] = sp[:legend] != :none end elseif st == :pie From b091d95eb2af94fc689a13e6a1f4d31ba46d99b2 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 18 Jun 2017 17:56:47 +0200 Subject: [PATCH 02/11] turn off colorbar for wireframe --- src/backends/plotly.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index b7520e23..c9cd8e22 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -501,6 +501,7 @@ function plotly_series(plt::Plot, series::Series) :highlightwidth => series[:linewidth], ) d_out[:contours] = KW(:x => wirelines, :y => wirelines, :z => wirelines) + d_out[:showscale] = false else d_out[:colorscale] = plotly_colorscale(series[:fillcolor], series[:fillalpha]) if series[:fill_z] != nothing From 47c51b28c17e0f02c60daec9256fbfa55b3f9cf1 Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Mon, 19 Jun 2017 18:06:08 -0700 Subject: [PATCH 03/11] gr: heatmaps now respect xlim/ylim specifications Fixes https://github.com/JuliaPlots/Plots.jl/issues/942 --- src/backends/gr.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index feb2e5eb..4d5d3dd4 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -886,7 +886,8 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) round(Int, blue(c) * 255) << 16 + round(Int, green(c) * 255) << 8 + round(Int, red(c) * 255) ), colors) - GR.drawimage(xmin, xmax, ymax, ymin, length(x), length(y), rgba) + w, h = length(x), length(y) + GR.drawimage(0.5, w + 0.5, h + 0.5, 0.5, w, h, rgba) cmap && gr_colorbar(sp) elseif st in (:path3d, :scatter3d) From e35b2ec3ff9af6e717a290b5a7bc507a9b3ff6c3 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Thu, 22 Jun 2017 18:51:03 +0200 Subject: [PATCH 04/11] replace deprecated DateTime convert methods --- src/recipes.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/recipes.jl b/src/recipes.jl index 64dd2c00..ce3533eb 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -970,11 +970,11 @@ abline!(args...; kw...) = abline!(current(), args...; kw...) # ------------------------------------------------- # Dates -dateformatter(dt) = string(convert(Date, dt)) -datetimeformatter(dt) = string(convert(DateTime, dt)) +dateformatter(dt) = string(Date(Dates.UTD(dt))) +datetimeformatter(dt) = string(DateTime(Dates.UTM(dt))) -@recipe f(::Type{Date}, dt::Date) = (dt -> convert(Int, dt), dateformatter) -@recipe f(::Type{DateTime}, dt::DateTime) = (dt -> convert(Int, dt), datetimeformatter) +@recipe f(::Type{Date}, dt::Date) = (dt -> Dates.value(dt), dateformatter) +@recipe f(::Type{DateTime}, dt::DateTime) = (dt -> Dates.value(dt), datetimeformatter) # ------------------------------------------------- # Complex Numbers From 356a5b6136ab187814b2c51ade987a2d2c483713 Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Thu, 22 Jun 2017 12:56:41 -0700 Subject: [PATCH 05/11] gr: fixed heatmap bug --- src/backends/gr.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 4d5d3dd4..8ef80de0 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -873,6 +873,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) cmap && gr_colorbar(sp) elseif st == :heatmap + xmin, xmax, ymin, ymax = data_lims zmin, zmax = gr_lims(zaxis, true) clims = sp[:clims] if is_2tuple(clims) @@ -887,7 +888,10 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) round(Int, green(c) * 255) << 8 + round(Int, red(c) * 255) ), colors) w, h = length(x), length(y) - GR.drawimage(0.5, w + 0.5, h + 0.5, 0.5, w, h, rgba) + GR.drawimage(xmin - 0.5 * (xmax - xmin) / (w - 1), + xmax + 0.5 * (xmax - xmin) / (w - 1), + ymax + 0.5 * (ymax - ymin) / (h - 1), + ymin - 0.5 * (ymax - ymin) / (h - 1), w, h, rgba) cmap && gr_colorbar(sp) elseif st in (:path3d, :scatter3d) From 46ae505bab3ecd0ed770107935471eefe6d079a5 Mon Sep 17 00:00:00 2001 From: Josef Heinen Date: Thu, 22 Jun 2017 15:31:13 -0700 Subject: [PATCH 06/11] gr: implemented "old" heatmap behaviour --- src/backends/gr.jl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 8ef80de0..b9a09d61 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -544,6 +544,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) viewport_plotarea[:] = gr_viewport_from_bbox(sp, plotarea(sp), w, h, viewport_canvas) # get data limits data_lims = gr_xy_axislims(sp) + xy_lims = data_lims ratio = sp[:aspect_ratio] if ratio != :none @@ -586,6 +587,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) if st == :heatmap outside_ticks = true x, y = heatmap_edges(series[:x]), heatmap_edges(series[:y]) + xy_lims = x[1], x[end], y[1], y[end] expand_extrema!(sp[:xaxis], x) expand_extrema!(sp[:yaxis], y) data_lims = gr_xy_axislims(sp) @@ -873,7 +875,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) cmap && gr_colorbar(sp) elseif st == :heatmap - xmin, xmax, ymin, ymax = data_lims + xmin, xmax, ymin, ymax = xy_lims zmin, zmax = gr_lims(zaxis, true) clims = sp[:clims] if is_2tuple(clims) @@ -888,10 +890,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) round(Int, green(c) * 255) << 8 + round(Int, red(c) * 255) ), colors) w, h = length(x), length(y) - GR.drawimage(xmin - 0.5 * (xmax - xmin) / (w - 1), - xmax + 0.5 * (xmax - xmin) / (w - 1), - ymax + 0.5 * (ymax - ymin) / (h - 1), - ymin - 0.5 * (ymax - ymin) / (h - 1), w, h, rgba) + GR.drawimage(xmin, xmax, ymax, ymin, w, h, rgba) cmap && gr_colorbar(sp) elseif st in (:path3d, :scatter3d) From 2f1c70e49f1107d309aa0a6ce60cd80bde28426b Mon Sep 17 00:00:00 2001 From: Christina Lee Date: Wed, 28 Jun 2017 11:42:16 -0700 Subject: [PATCH 07/11] fixing deprecation warning --- src/recipes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/recipes.jl b/src/recipes.jl index ce3533eb..f5cb9b73 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -703,7 +703,7 @@ end function error_coords(xorig, yorig, ebar) # init empty x/y, and zip errors if passed Tuple{Vector,Vector} - x, y = Array(float_extended_type(xorig), 0), Array(Float64, 0) + x, y = Array{float_extended_type(xorig)}(0), Array{Float64}(0) # for each point, create a line segment from the bottom to the top of the errorbar for i = 1:max(length(xorig), length(yorig)) xi = _cycle(xorig, i) From de043eeaa2f975955f5602e2dc81e31d090ba4e8 Mon Sep 17 00:00:00 2001 From: Robin Deits Date: Wed, 5 Jul 2017 17:12:39 -0400 Subject: [PATCH 08/11] switch from FixedSizeArrays to StaticArrays.FixedSizeArrays --- REQUIRE | 2 +- src/Plots.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/REQUIRE b/REQUIRE index 44e1623d..3d6ae3c9 100644 --- a/REQUIRE +++ b/REQUIRE @@ -4,7 +4,7 @@ RecipesBase 0.2.0 PlotUtils 0.4.1 PlotThemes 0.1.3 Reexport -FixedSizeArrays +StaticArrays 0.5 FixedPointNumbers 0.3 Measures Showoff diff --git a/src/Plots.jl b/src/Plots.jl index a23d6a8d..f5a8df9a 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -3,7 +3,7 @@ __precompile__(true) module Plots using Reexport -using FixedSizeArrays +using StaticArrays.FixedSizeArrays @reexport using RecipesBase import RecipesBase: plot, animate using Base.Meta From 409cf2c6309ab5102c94e40ff7fc2d3a9b31c006 Mon Sep 17 00:00:00 2001 From: JackDevine Date: Wed, 12 Jul 2017 17:37:37 +1200 Subject: [PATCH 09/11] Fixed a deprecation warning on the pyplot backend The follwing code created a deprecation warining: using Plots; pyplot() plot([1,2,3,4], [2,3,4,5], yscale=:log10) --- src/backends/pyplot.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index f7ca62ff..251b6377 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -926,7 +926,7 @@ function py_compute_axis_minval(axis::Axis) for series in series_list(sp) v = series.d[axis[:letter]] if !isempty(v) - minval = NaNMath.min(minval, ignorenan_minimum(abs(v))) + minval = NaNMath.min(minval, ignorenan_minimum(abs.(v))) end end end From aec30301a1f0ae3424b1c36925318d89bb95ab5f Mon Sep 17 00:00:00 2001 From: Pearl Li Date: Wed, 12 Jul 2017 16:19:29 -0400 Subject: [PATCH 10/11] Add fillrange for Plotly --- src/backends/plotly.jl | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index c9cd8e22..914a1f0a 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -435,6 +435,7 @@ function plotly_series(plt::Plot, series::Series) isscatter = st in (:scatter, :scatter3d, :scattergl) hasmarker = isscatter || series[:markershape] != :none hasline = st in (:path, :path3d) + hasfillrange = st in (:path, :scatter, :scattergl) && isa(series[:fillrange], AbstractVector) # for surface types, set the data if st in (:heatmap, :contour, :surface, :wireframe) @@ -461,8 +462,11 @@ function plotly_series(plt::Plot, series::Series) if series[:fillrange] == true || series[:fillrange] == 0 d_out[:fill] = "tozeroy" d_out[:fillcolor] = rgba_string(series[:fillcolor]) + elseif isa(series[:fillrange], AbstractVector) + d_out[:fill] = "tonexty" + d_out[:fillcolor] = rgba_string(series[:fillcolor]) elseif !(series[:fillrange] in (false, nothing)) - warn("fillrange ignored... plotly only supports filling to zero. fillrange: $(series[:fillrange])") + warn("fillrange ignored... plotly only supports filling to zero and to a vector of values. fillrange: $(series[:fillrange])") end d_out[:x], d_out[:y] = x, y @@ -576,7 +580,18 @@ function plotly_series(plt::Plot, series::Series) plotly_polar!(d_out, series) plotly_hover!(d_out, series[:hover]) - [d_out] + if hasfillrange + # if hasfillrange is true, return two dictionaries (one for original + # series, one for series being filled to) instead of one + d_out_fillrange = copy(d_out) + d_out_fillrange[:y] = series[:fillrange] + delete!(d_out_fillrange, :fill) + delete!(d_out_fillrange, :fillcolor) + + return [d_out_fillrange, d_out] + else + return [d_out] + end end function plotly_series_shapes(plt::Plot, series::Series) From 2a0d5a0a039498d675a86e7e48e67f93ce835745 Mon Sep 17 00:00:00 2001 From: Pearl Li Date: Wed, 12 Jul 2017 17:04:01 -0400 Subject: [PATCH 11/11] Hide legend entry for series being filled to --- src/backends/plotly.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 914a1f0a..440884a9 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -585,6 +585,7 @@ function plotly_series(plt::Plot, series::Series) # series, one for series being filled to) instead of one d_out_fillrange = copy(d_out) d_out_fillrange[:y] = series[:fillrange] + d_out_fillrange[:showlegend] = false delete!(d_out_fillrange, :fill) delete!(d_out_fillrange, :fillcolor)