From 1aa780f0a21218ba0ec34d6886e6ec0718efade9 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 17 Nov 2017 11:33:10 +0100 Subject: [PATCH 1/3] change legend symbols for shapes and filled plots on pyplot --- src/backends/pyplot.jl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index d325b21b..a29b81b7 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -2,7 +2,7 @@ # https://github.com/stevengj/PyPlot.jl @require Revise begin - Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "pyplot.jl")) + Revise.track(Plots, joinpath(Pkg.dir("Plots"), "src", "backends", "pyplot.jl")) end const _pyplot_attr = merge_with_base_supported([ @@ -1009,7 +1009,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) for lab in cb[:ax][:yaxis][:get_ticklabels]() lab[:set_fontsize](py_dpi_scale(plt, sp[:yaxis][:tickfont].pointsize)) lab[:set_family](sp[:yaxis][:tickfont].family) - end + end sp.attr[:cbar_handle] = cb sp.attr[:cbar_ax] = cbax end @@ -1221,10 +1221,11 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) for series in series_list(sp) if should_add_to_legend(series) # add a line/marker and a label - push!(handles, if series[:seriestype] == :shape - PyPlot.plt[:Line2D]((0,1),(0,0), - color = py_color(_cycle(series[:fillcolor],1)), - linewidth = py_dpi_scale(plt, 4) + push!(handles, if series[:seriestype] == :shape || series[:fillrange] != nothing + pypatches[:Patch]( + edgecolor = py_color(_cycle(series[:linecolor],1)), + facecolor = py_color(_cycle(series[:fillcolor],1)), + linewidth = py_dpi_scale(plt, series[:linewidth]) ) elseif series[:seriestype] == :path PyPlot.plt[:Line2D]((0,1),(0,0), From 4bc01b92bd3f980899429f75bc24f104da9a73f6 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 17 Nov 2017 12:59:20 +0100 Subject: [PATCH 2/3] avoid too big linewidths in legend --- src/backends/pyplot.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index a29b81b7..fcac84c6 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1225,12 +1225,12 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) pypatches[:Patch]( edgecolor = py_color(_cycle(series[:linecolor],1)), facecolor = py_color(_cycle(series[:fillcolor],1)), - linewidth = py_dpi_scale(plt, series[:linewidth]) + linewidth = py_dpi_scale(plt, clamp(series[:linewidth], 0, 5)), ) elseif series[:seriestype] == :path - PyPlot.plt[:Line2D]((0,1),(0,0), + PyPlot.plt[:Line2D]((0, 1),(0,0), color = py_color(_cycle(series[:fillcolor],1)), - linewidth = py_dpi_scale(plt, 1), + linewidth = py_dpi_scale(plt, clamp(series[:linewidth], 0, 5)), marker = py_marker(series[:markershape]), markeredgecolor = py_markerstrokecolor(series), markerfacecolor = py_markercolor(series) From 4bfb56247714a5c656c3b7be1356a8515e8c9628 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Fri, 17 Nov 2017 13:01:13 +0100 Subject: [PATCH 3/3] remove extra space --- 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 fcac84c6..1ef9a2d7 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1228,7 +1228,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) linewidth = py_dpi_scale(plt, clamp(series[:linewidth], 0, 5)), ) elseif series[:seriestype] == :path - PyPlot.plt[:Line2D]((0, 1),(0,0), + PyPlot.plt[:Line2D]((0,1),(0,0), color = py_color(_cycle(series[:fillcolor],1)), linewidth = py_dpi_scale(plt, clamp(series[:linewidth], 0, 5)), marker = py_marker(series[:markershape]),