From 17e8bc6949a8ca2015fdbdc4af4d8fa1387995cd Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 30 May 2018 16:13:39 +0200 Subject: [PATCH 1/4] set legend alpha in pyplot --- src/backends/pyplot.jl | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 719496fe..19dfb72c 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1282,27 +1282,30 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) # if anything was added, call ax.legend and set the colors if !isempty(handles) + fgcolor = py_color(sp[:foreground_color_legend]) leg = ax[:legend](handles, labels, loc = get(_pyplot_legend_pos, leg, "best"), scatterpoints = 1, - fontsize = py_dpi_scale(plt, sp[:legendfontsize]) - # family = sp[:legendfont].family - # framealpha = 0.6 + fontsize = py_dpi_scale(plt, sp[:legendfontsize]), + # family = sp[:legendfont].family, + # framealpha = 0.6, + facecolor = py_color(sp[:background_color_legend]), + edgecolor = py_color(sp[:foreground_color_legend]), + framealpha = alpha(sp[:background_color_legend]), ) leg[:set_zorder](1000) sp[:legendtitle] != nothing && leg[:set_title](sp[:legendtitle]) - fgcolor = py_color(sp[:foreground_color_legend]) lfcolor = py_color(sp[:legendfontcolor]) for txt in leg[:get_texts]() PyPlot.plt[:setp](txt, color = lfcolor, family = sp[:legendfontfamily]) end # set some legend properties - frame = leg[:get_frame]() - frame[set_facecolor_sym](py_color(sp[:background_color_legend])) - frame[:set_edgecolor](fgcolor) + # frame = leg[:get_frame]() + # frame[set_facecolor_sym](py_color(sp[:background_color_legend])) + # frame[:set_edgecolor](fgcolor) end end end From 56cf5249f9778fa5b8fe08799f8a5c5e1922b94a Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 30 May 2018 16:18:56 +0200 Subject: [PATCH 2/4] remove extra line --- 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 19dfb72c..be3adbc7 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1282,7 +1282,6 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) # if anything was added, call ax.legend and set the colors if !isempty(handles) - fgcolor = py_color(sp[:foreground_color_legend]) leg = ax[:legend](handles, labels, loc = get(_pyplot_legend_pos, leg, "best"), @@ -1297,6 +1296,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) leg[:set_zorder](1000) sp[:legendtitle] != nothing && leg[:set_title](sp[:legendtitle]) + # fgcolor = py_color(sp[:foreground_color_legend]) lfcolor = py_color(sp[:legendfontcolor]) for txt in leg[:get_texts]() PyPlot.plt[:setp](txt, color = lfcolor, family = sp[:legendfontfamily]) From 4a55467eef2a6336e96ae716f987c54380e55e4f Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 30 May 2018 16:20:19 +0200 Subject: [PATCH 3/4] add plot_color --- 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 be3adbc7..d55b3f42 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1291,7 +1291,7 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) # framealpha = 0.6, facecolor = py_color(sp[:background_color_legend]), edgecolor = py_color(sp[:foreground_color_legend]), - framealpha = alpha(sp[:background_color_legend]), + framealpha = alpha(plot_color(sp[:background_color_legend])), ) leg[:set_zorder](1000) sp[:legendtitle] != nothing && leg[:set_title](sp[:legendtitle]) From bf518a961ecf77f4f8768ad4d78daab938f7a2ed Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 30 May 2018 16:28:56 +0200 Subject: [PATCH 4/4] clean up --- src/backends/pyplot.jl | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index d55b3f42..0110d086 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1287,8 +1287,6 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) loc = get(_pyplot_legend_pos, leg, "best"), scatterpoints = 1, fontsize = py_dpi_scale(plt, sp[:legendfontsize]), - # family = sp[:legendfont].family, - # framealpha = 0.6, facecolor = py_color(sp[:background_color_legend]), edgecolor = py_color(sp[:foreground_color_legend]), framealpha = alpha(plot_color(sp[:background_color_legend])), @@ -1296,16 +1294,9 @@ function py_add_legend(plt::Plot, sp::Subplot, ax) leg[:set_zorder](1000) sp[:legendtitle] != nothing && leg[:set_title](sp[:legendtitle]) - # fgcolor = py_color(sp[:foreground_color_legend]) - lfcolor = py_color(sp[:legendfontcolor]) for txt in leg[:get_texts]() - PyPlot.plt[:setp](txt, color = lfcolor, family = sp[:legendfontfamily]) + PyPlot.plt[:setp](txt, color = py_color(sp[:legendfontcolor]), family = sp[:legendfontfamily]) end - - # set some legend properties - # frame = leg[:get_frame]() - # frame[set_facecolor_sym](py_color(sp[:background_color_legend])) - # frame[:set_edgecolor](fgcolor) end end end