From 09de2ebc0ef986d5574874b7214fd12af269f015 Mon Sep 17 00:00:00 2001 From: isentropic Date: Sat, 25 Apr 2020 00:15:00 +0900 Subject: [PATCH] Minorgrid and minorticks for pyplot (#2621) * Minor grids for pyplot * Minorgrid and minorticks setup for pyplot --- src/backends/pyplot.jl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 72ae575d..ed7ba3fd 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1134,6 +1134,35 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) else pyaxis."grid"(false) end + # + + if axis[:minorticks] > 1 + pyaxis."set_minor_locator"(PyPlot.matplotlib.ticker.AutoMinorLocator(axis[:minorticks])) + pyaxis."set_tick_params"( + which = "minor", + direction = axis[:tick_direction] == :out ? "out" : "in", + width=py_thickness_scale(plt, intensity)) + end + + if axis[:minorgrid] + if !(axis[:minorticks] > 1) # Check if ticks were already configured + ax."minorticks_on"() + end + pyaxis."set_tick_params"( + which = "minor", + direction = axis[:tick_direction] == :out ? "out" : "in", + width=py_thickness_scale(plt, intensity)) + + pyaxis."grid"(true, + which = "minor", + color = fgcolor, + linestyle = py_linestyle(:line, axis[:minorgridstyle]), + linewidth = py_thickness_scale(plt, axis[:minorgridlinewidth]), + alpha = axis[:minorgridalpha]) + end + + + py_set_axis_colors(sp, ax, axis) end