sample ticks if too many discrete values; use get_ticks in plotly to fix discrete ticks; allow ticks==false in pyplot; closes #356

This commit is contained in:
Thomas Breloff 2016-07-06 16:51:54 -04:00
parent aec162c50e
commit 0cc1bd2dc6
3 changed files with 10 additions and 3 deletions

View File

@ -122,7 +122,14 @@ function get_ticks(axis::Axis)
ticks = axis[:ticks] ticks = axis[:ticks]
dvals = axis[:discrete_values] dvals = axis[:discrete_values]
if !isempty(dvals) && ticks == :auto if !isempty(dvals) && ticks == :auto
axis[:continuous_values], dvals cv, dv = axis[:continuous_values], dvals
# TODO: better/smarter cutoff values for sampling ticks
if length(cv) > 30
rng = Int[round(Int,i) for i in linspace(1, length(cv), 15)]
cv[rng], dv[rng]
else
cv, dv
end
else else
ticks ticks
end end

View File

@ -190,7 +190,7 @@ function plotly_axis(axis::Axis, sp::Subplot)
end end
# ticks # ticks
ticks = axis[:ticks] ticks = get_ticks(axis)
if ticks != :auto if ticks != :auto
ttype = ticksType(ticks) ttype = ticksType(ticks)
if ttype == :ticks if ttype == :ticks

View File

@ -935,7 +935,7 @@ end
function py_set_ticks(ax, ticks, letter) function py_set_ticks(ax, ticks, letter)
ticks == :auto && return ticks == :auto && return
axis = ax[Symbol(letter,"axis")] axis = ax[Symbol(letter,"axis")]
if ticks == :none || ticks == nothing if ticks == :none || ticks == nothing || ticks == false
kw = KW() kw = KW()
for dir in (:top,:bottom,:left,:right) for dir in (:top,:bottom,:left,:right)
kw[dir] = kw[Symbol(:label,dir)] = "off" kw[dir] = kw[Symbol(:label,dir)] = "off"