Implement :native ticks option.

This commit is contained in:
Andrew Palugniok 2018-02-21 10:09:57 +00:00
parent 3ac9f3d9cc
commit 06466b060f
5 changed files with 10 additions and 7 deletions

View File

@ -234,6 +234,9 @@ function get_ticks(axis::Axis)
ticks = _transform_ticks(axis[:ticks]) ticks = _transform_ticks(axis[:ticks])
ticks in (nothing, false) && return nothing ticks in (nothing, false) && return nothing
# treat :native ticks as :auto
ticks = ticks == :native ? :auto : ticks
dvals = axis[:discrete_values] dvals = axis[:discrete_values]
cv, dv = if !isempty(dvals) && ticks == :auto cv, dv = if !isempty(dvals) && ticks == :auto
# discrete ticks... # discrete ticks...

View File

@ -222,7 +222,7 @@ function gr_polaraxes(rmin::Real, rmax::Real, sp::Subplot)
sinf = sind.(a) sinf = sind.(a)
cosf = cosd.(a) cosf = cosd.(a)
rtick_values, rtick_labels = get_ticks(yaxis) rtick_values, rtick_labels = get_ticks(yaxis)
if yaxis[:formatter] == :scientific && yaxis[:ticks] == :auto if yaxis[:formatter] == :scientific && yaxis[:ticks] in (:auto, :native)
rtick_labels = convert_sci_unicode(rtick_labels) rtick_labels = convert_sci_unicode(rtick_labels)
end end
@ -884,7 +884,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
# use xor ($) to get the right y coords # use xor ($) to get the right y coords
xi, yi = GR.wctondc(cv, sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? ymax : ymin) xi, yi = GR.wctondc(cv, sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? ymax : ymin)
# @show cv dv ymin xi yi flip mirror (flip $ mirror) # @show cv dv ymin xi yi flip mirror (flip $ mirror)
if xaxis[:ticks] == :auto if xaxis[:ticks] in (:auto, :native)
# ensure correct dispatch in gr_text for automatic log ticks # ensure correct dispatch in gr_text for automatic log ticks
if xaxis[:scale] in _logScales if xaxis[:scale] in _logScales
dv = string(dv, "\\ ") dv = string(dv, "\\ ")
@ -903,7 +903,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
# use xor ($) to get the right y coords # use xor ($) to get the right y coords
xi, yi = GR.wctondc(sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? xmax : xmin, cv) xi, yi = GR.wctondc(sp[:framestyle] == :origin ? 0 : xor(flip, mirror) ? xmax : xmin, cv)
# @show cv dv xmin xi yi # @show cv dv xmin xi yi
if yaxis[:ticks] == :auto if yaxis[:ticks] in (:auto, :native)
# ensure correct dispatch in gr_text for automatic log ticks # ensure correct dispatch in gr_text for automatic log ticks
if yaxis[:scale] in _logScales if yaxis[:scale] in _logScales
dv = string(dv, "\\ ") dv = string(dv, "\\ ")

View File

@ -314,7 +314,7 @@ function pgf_axis(sp::Subplot, letter)
kw[Symbol(letter,:max)] = lims[2] kw[Symbol(letter,:max)] = lims[2]
end end
if !(axis[:ticks] in (nothing, false, :none)) && framestyle != :none if !(axis[:ticks] in (nothing, false, :none, :native)) && framestyle != :none
ticks = get_ticks(axis) ticks = get_ticks(axis)
#pgf plot ignores ticks with angle below 90 when xmin = 90 so shift values #pgf plot ignores ticks with angle below 90 when xmin = 90 so shift values
tick_values = ispolar(sp) && letter == :x ? [rad2deg.(ticks[1])[3:end]..., 360, 405] : ticks[1] tick_values = ispolar(sp) && letter == :x ? [rad2deg.(ticks[1])[3:end]..., 360, 405] : ticks[1]

View File

@ -273,8 +273,8 @@ function plotly_axis(axis::Axis, sp::Subplot)
end end
# ticks # ticks
ticks = get_ticks(axis) if axis[:ticks] != :native
if ticks != :auto ticks = get_ticks(axis)
ttype = ticksType(ticks) ttype = ticksType(ticks)
if ttype == :ticks if ttype == :ticks
ax[:tickmode] = "array" ax[:tickmode] = "array"

View File

@ -1069,7 +1069,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
if sp[:framestyle] == :origin && length(ticks) > 1 if sp[:framestyle] == :origin && length(ticks) > 1
ticks[2][ticks[1] .== 0] = "" ticks[2][ticks[1] .== 0] = ""
end end
py_set_ticks(ax, ticks, letter) axis[:ticks] != :native ? py_set_ticks(ax, ticks, letter) : nothing
pyaxis[:set_tick_params](direction = axis[:tick_direction] == :out ? "out" : "in") pyaxis[:set_tick_params](direction = axis[:tick_direction] == :out ? "out" : "in")
ax[Symbol("set_", letter, "label")](axis[:guide]) ax[Symbol("set_", letter, "label")](axis[:guide])
if get(axis.d, :flip, false) if get(axis.d, :flip, false)