From ea0100fa5b511a9fc875fed26aa758958b2ebcec Mon Sep 17 00:00:00 2001 From: sfoo Date: Tue, 21 Feb 2017 06:41:03 -0800 Subject: [PATCH 01/10] Changed grid to Axis attribute --- src/Plots.jl | 6 ++++++ src/arg_desc.jl | 2 +- src/args.jl | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Plots.jl b/src/Plots.jl index 337880da..cf8fddd5 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -50,6 +50,8 @@ export yflip!, xaxis!, yaxis!, + xgrid!, + ygrid!, xlims, ylims, @@ -195,6 +197,8 @@ xflip!(flip::Bool = true; kw...) = plot!(; xflip = flip yflip!(flip::Bool = true; kw...) = plot!(; yflip = flip, kw...) xaxis!(args...; kw...) = plot!(; xaxis = args, kw...) yaxis!(args...; kw...) = plot!(; yaxis = args, kw...) +xgrid!(grid::Bool = true; kw...) = plot!(; xgrid = grid, kw...) +ygrid!(grid::Bool = true; kw...) = plot!(; ygrid = grid, kw...) let PlotOrSubplot = Union{Plot, Subplot} title!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; title = s, kw...) @@ -218,6 +222,8 @@ let PlotOrSubplot = Union{Plot, Subplot} yflip!(plt::PlotOrSubplot, flip::Bool = true; kw...) = plot!(plt; yflip = flip, kw...) xaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; xaxis = args, kw...) yaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; yaxis = args, kw...) + xgrid!(plt::PlotOrSubplot, grid::Bool = true; kw...) = plot!(plt; xgrid = grid, kw...) + ygrid!(plt::PlotOrSubplot, grid::Bool = true; kw...) = plot!(plt; ygrid = grid, kw...) end diff --git a/src/arg_desc.jl b/src/arg_desc.jl index 4efbf1af..f05830be 100644 --- a/src/arg_desc.jl +++ b/src/arg_desc.jl @@ -83,7 +83,6 @@ const _arg_desc = KW( :colorbar => "Bool (show the colorbar?) or Symbol (colorbar position). Symbol values: `:none`, `:best`, `:right`, `:left`, `:top`, `:bottom`, `:legend` (matches legend value) (note: only some may be supported in each backend)", :clims => "`:auto` or NTuple{2,Number}. Fixes the limits of the colorbar.", :legendfont => "Font. Font of legend items.", -:grid => "Bool. Show the grid lines?", :annotations => "(x,y,text) tuple(s). Can be a single tuple or a list of them. Text can be String or PlotText (created with `text(args...)`) Add one-off text annotations at the x,y coordinates.", :projection => "Symbol or String. '3d' or 'polar'", :aspect_ratio => "Symbol (:equal) or Number. Plot area is resized so that 1 y-unit is the same size as `apect_ratio` x-units.", @@ -110,5 +109,6 @@ const _arg_desc = KW( :foreground_color_text => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of tick labels.", :foreground_color_guide => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of axis guides (axis labels).", :mirror => "Bool. Switch the side of the tick labels (right or top).", +:grid => "Bool. Show grid lines?" ) diff --git a/src/args.jl b/src/args.jl index 8f82fec0..0feb7cad 100644 --- a/src/args.jl +++ b/src/args.jl @@ -249,7 +249,6 @@ const _subplot_defaults = KW( :colorbar => :legend, :clims => :auto, :legendfont => font(8), - :grid => true, :annotations => [], # annotation tuples... list of (x,y,annotation) :projection => :none, # can also be :polar or :3d :aspect_ratio => :none, # choose from :none or :equal @@ -279,6 +278,7 @@ const _axis_defaults = KW( :discrete_values => [], :formatter => :auto, :mirror => false, + :grid => true, ) const _suppress_warnings = Set{Symbol}([ @@ -315,6 +315,7 @@ for letter in (:x,:y,:z) # :foreground_color_guide, # :discrete_values, # :formatter, + # :grid, # ) _axis_defaults_byletter[Symbol(letter,k)] = :match From 2634b0eec0ad175ec0fc0242df750720c115de24 Mon Sep 17 00:00:00 2001 From: sfoo Date: Tue, 21 Feb 2017 06:52:44 -0800 Subject: [PATCH 02/10] Fixed unknown package error --- src/Plots.jl | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Plots.jl b/src/Plots.jl index cf8fddd5..337880da 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -50,8 +50,6 @@ export yflip!, xaxis!, yaxis!, - xgrid!, - ygrid!, xlims, ylims, @@ -197,8 +195,6 @@ xflip!(flip::Bool = true; kw...) = plot!(; xflip = flip yflip!(flip::Bool = true; kw...) = plot!(; yflip = flip, kw...) xaxis!(args...; kw...) = plot!(; xaxis = args, kw...) yaxis!(args...; kw...) = plot!(; yaxis = args, kw...) -xgrid!(grid::Bool = true; kw...) = plot!(; xgrid = grid, kw...) -ygrid!(grid::Bool = true; kw...) = plot!(; ygrid = grid, kw...) let PlotOrSubplot = Union{Plot, Subplot} title!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; title = s, kw...) @@ -222,8 +218,6 @@ let PlotOrSubplot = Union{Plot, Subplot} yflip!(plt::PlotOrSubplot, flip::Bool = true; kw...) = plot!(plt; yflip = flip, kw...) xaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; xaxis = args, kw...) yaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; yaxis = args, kw...) - xgrid!(plt::PlotOrSubplot, grid::Bool = true; kw...) = plot!(plt; xgrid = grid, kw...) - ygrid!(plt::PlotOrSubplot, grid::Bool = true; kw...) = plot!(plt; ygrid = grid, kw...) end From b83916da136c4c403ee04a66a2708c6d95ded225 Mon Sep 17 00:00:00 2001 From: sfoo Date: Tue, 21 Feb 2017 07:04:13 -0800 Subject: [PATCH 03/10] Fixed arugments --- src/Plots.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Plots.jl b/src/Plots.jl index 337880da..cf8fddd5 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -50,6 +50,8 @@ export yflip!, xaxis!, yaxis!, + xgrid!, + ygrid!, xlims, ylims, @@ -195,6 +197,8 @@ xflip!(flip::Bool = true; kw...) = plot!(; xflip = flip yflip!(flip::Bool = true; kw...) = plot!(; yflip = flip, kw...) xaxis!(args...; kw...) = plot!(; xaxis = args, kw...) yaxis!(args...; kw...) = plot!(; yaxis = args, kw...) +xgrid!(grid::Bool = true; kw...) = plot!(; xgrid = grid, kw...) +ygrid!(grid::Bool = true; kw...) = plot!(; ygrid = grid, kw...) let PlotOrSubplot = Union{Plot, Subplot} title!(plt::PlotOrSubplot, s::AbstractString; kw...) = plot!(plt; title = s, kw...) @@ -218,6 +222,8 @@ let PlotOrSubplot = Union{Plot, Subplot} yflip!(plt::PlotOrSubplot, flip::Bool = true; kw...) = plot!(plt; yflip = flip, kw...) xaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; xaxis = args, kw...) yaxis!(plt::PlotOrSubplot, args...; kw...) = plot!(plt; yaxis = args, kw...) + xgrid!(plt::PlotOrSubplot, grid::Bool = true; kw...) = plot!(plt; xgrid = grid, kw...) + ygrid!(plt::PlotOrSubplot, grid::Bool = true; kw...) = plot!(plt; ygrid = grid, kw...) end From 337fc9ce9d3d2180bde4216f2e6d1be5d1e39544 Mon Sep 17 00:00:00 2001 From: sfoo Date: Tue, 21 Feb 2017 07:24:06 -0800 Subject: [PATCH 04/10] Removed :grid from pyplot.jl --- src/backends/pyplot.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 68f45be9..6504a5d8 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1057,11 +1057,11 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) lab[:set_family](axis[:tickfont].family) lab[:set_rotation](axis[:rotation]) end - if sp[:grid] - fgcolor = py_color(sp[:foreground_color_grid]) - pyaxis[:grid](true, color = fgcolor) - ax[:set_axisbelow](true) - end +# if sp[:grid] +# fgcolor = py_color(sp[:foreground_color_grid]) +# pyaxis[:grid](true, color = fgcolor) +# ax[:set_axisbelow](true) +# end py_set_axis_colors(ax, axis) end From 1e31e1d2df91ac376e5e18053c5a06fd95875a64 Mon Sep 17 00:00:00 2001 From: sfoo Date: Tue, 21 Feb 2017 21:14:18 -0800 Subject: [PATCH 05/10] Key error attempt: changed sp to axis --- src/backends/pyplot.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 6504a5d8..a34f5da2 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1062,6 +1062,11 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) # pyaxis[:grid](true, color = fgcolor) # ax[:set_axisbelow](true) # end + if axis[:grid] + fgcolor = py_color(axix[:foreground_color_grid]) + pyaxis[:grid](true, color = fgcolor) + ax[:set_axisbelow](true) + end py_set_axis_colors(ax, axis) end From f2929ef9062115c363c90682f38b8c9fcc09de51 Mon Sep 17 00:00:00 2001 From: sfoo Date: Tue, 21 Feb 2017 21:18:32 -0800 Subject: [PATCH 06/10] Fixed axis spelling --- 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 a34f5da2..589e0777 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1063,7 +1063,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) # ax[:set_axisbelow](true) # end if axis[:grid] - fgcolor = py_color(axix[:foreground_color_grid]) + fgcolor = py_color(axis[:foreground_color_grid]) pyaxis[:grid](true, color = fgcolor) ax[:set_axisbelow](true) end From 32d2caa5f1a30de6cabaafe5e3e80f96ef3f966f Mon Sep 17 00:00:00 2001 From: sfoo Date: Tue, 21 Feb 2017 21:24:39 -0800 Subject: [PATCH 07/10] :foreground_color_grid not found, changed back to sp[:fore...] --- 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 589e0777..467f78b7 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1063,7 +1063,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) # ax[:set_axisbelow](true) # end if axis[:grid] - fgcolor = py_color(axis[:foreground_color_grid]) + fgcolor = py_color(sp[:foreground_color_grid]) pyaxis[:grid](true, color = fgcolor) ax[:set_axisbelow](true) end From 53740a0da5ae4996b5325cdb5366369c32eebd91 Mon Sep 17 00:00:00 2001 From: sfoo Date: Tue, 21 Feb 2017 21:32:35 -0800 Subject: [PATCH 08/10] Remove commented code. Tested grid functionality prior to PR --- src/backends/pyplot.jl | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 467f78b7..3f0e6840 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1057,11 +1057,6 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) lab[:set_family](axis[:tickfont].family) lab[:set_rotation](axis[:rotation]) end -# if sp[:grid] -# fgcolor = py_color(sp[:foreground_color_grid]) -# pyaxis[:grid](true, color = fgcolor) -# ax[:set_axisbelow](true) -# end if axis[:grid] fgcolor = py_color(sp[:foreground_color_grid]) pyaxis[:grid](true, color = fgcolor) From 581dd220b171e7c921625b3f1183243af1a15892 Mon Sep 17 00:00:00 2001 From: sfoo Date: Wed, 22 Feb 2017 21:50:03 -0800 Subject: [PATCH 09/10] Added independent grid lines on Plotly --- src/backends/plotly.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index bbdd29b9..5d10bf0e 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -212,7 +212,7 @@ function plotly_axis(axis::Axis, sp::Subplot) letter = axis[:letter] ax = KW( :title => axis[:guide], - :showgrid => sp[:grid], + :showgrid => axis[:grid], :zeroline => false, :ticks => "inside", ) From 38d403570b117dd0b90c9ac2a5b6d541566ea211 Mon Sep 17 00:00:00 2001 From: sfoo Date: Thu, 23 Feb 2017 14:31:20 -0800 Subject: [PATCH 10/10] GR backend test --- src/backends/gr.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index b092edd7..64467bc6 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -635,7 +635,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) # @show xticks yticks #spine_segs grid_segs # draw the grid lines - if sp[:grid] + if axis[:grid] # gr_set_linecolor(sp[:foreground_color_grid]) # GR.grid(xtick, ytick, 0, 0, majorx, majory) gr_set_line(1, :dot, sp[:foreground_color_grid])