# HG changeset patch # User Rik # Date 1434841250 25200 # Node ID ce8fda51d236fa9eb583718633d337e4f53ee414 # Parent f357e076776f7f09a56acf1ecc4d5ba7ec763a20 Set correct number of axis tickmarks when axis limits are manually configured (bug #45356). * graphics.cc (axes::properties::calc_ticks_and_lims): When axis limits are "manual", make sure that ticks are within the manual limits. Add BIST test for correct behavior. diff -r f357e076776f -r ce8fda51d236 libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc Wed Jun 17 16:52:09 2015 +0200 +++ b/libinterp/corefcn/graphics.cc Sat Jun 20 16:00:50 2015 -0700 @@ -7087,6 +7087,14 @@ } lims = tmp_lims; } + else + { + // adjust min and max tics to be within limits + if (i1*tick_sep < lo) + i1++; + if (i2*tick_sep > hi) + i2--; + } Matrix tmp_ticks (1, i2-i1+1); for (int i = 0; i <= i2-i1; i++) @@ -7119,6 +7127,19 @@ mticks = tmp_mticks; } +/* +%!test # Bug #45356 +%! hf = figure ("visible", "off"); +%! unwind_protect +%! plot (1:10); +%! xlim ([4.75, 8.5]); +%! tics = get (gca, "xtick"); +%! assert (tics, [5 6 7 8]); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect +*/ + void axes::properties::calc_ticklabels (const array_property& ticks, any_property& labels, bool logscale)