comparison libinterp/corefcn/graphics.cc @ 18706:ec55f6870efb

Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449). * graphics.cc (axes::properties::calc_ticks_and_lims): Always use a tick separation of 1 order of magnitude for logscale plots.
author Rik <rik@octave.org>
date Wed, 30 Apr 2014 08:24:08 -0700
parents 44f0d1a53ead
children d57a83f2d73e
comparison
equal deleted inserted replaced
18705:60df2fd04293 18706:ec55f6870efb
6422 double hi = (lims.get ().matrix_value ()) (1); 6422 double hi = (lims.get ().matrix_value ()) (1);
6423 bool is_negative = lo < 0 && hi < 0; 6423 bool is_negative = lo < 0 && hi < 0;
6424 double tmp; 6424 double tmp;
6425 // FIXME: should this be checked for somewhere else? (i.e. set{x,y,z}lim) 6425 // FIXME: should this be checked for somewhere else? (i.e. set{x,y,z}lim)
6426 if (hi < lo) 6426 if (hi < lo)
6427 { 6427 std::swap (hi, lo);
6428 tmp = hi;
6429 hi = lo;
6430 lo = tmp;
6431 }
6432 6428
6433 if (is_logscale) 6429 if (is_logscale)
6434 { 6430 {
6435 if (is_negative) 6431 if (is_negative)
6436 { 6432 {
6443 hi = std::log10 (hi); 6439 hi = std::log10 (hi);
6444 lo = std::log10 (lo); 6440 lo = std::log10 (lo);
6445 } 6441 }
6446 } 6442 }
6447 6443
6448 double tick_sep = calc_tick_sep (lo , hi); 6444 double tick_sep;
6449 6445
6450 if (is_logscale && ! (xisinf (hi) || xisinf (lo))) 6446 if (is_logscale)
6451 { 6447 {
6452 // FIXME: what if (hi-lo) < tick_sep? 6448 if (! (xisinf (hi) || xisinf (lo)))
6453 // ex: loglog ([1 1.1]) 6449 tick_sep = 1; // Tick is every order of magnitude (bug #39449)
6454 tick_sep = std::max (tick_sep, 1.); 6450 else
6455 tick_sep = std::ceil (tick_sep); 6451 tick_sep = 0;
6456 } 6452 }
6453 else
6454 tick_sep = calc_tick_sep (lo , hi);
6457 6455
6458 int i1 = static_cast<int> (gnulib::floor (lo / tick_sep)); 6456 int i1 = static_cast<int> (gnulib::floor (lo / tick_sep));
6459 int i2 = static_cast<int> (std::ceil (hi / tick_sep)); 6457 int i2 = static_cast<int> (std::ceil (hi / tick_sep));
6460 6458
6461 if (limmode_is_auto) 6459 if (limmode_is_auto)