Skip to content

Commit

Permalink
Re #11422 Avoid plotting <0 for n == +ve even integer
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew D Jones authored and Matthew D Jones committed Aug 12, 2015
1 parent 565d3d4 commit e736cd7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Code/Mantid/MantidPlot/src/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,8 @@ void Graph::setAxisScale(int axis, double start, double end, int type, double st
}
else if (type == GraphOptions::Power)
{
if (start <= 0 && sc_engine->nthPower() < 0)
double const nth_power = sc_engine->nthPower();
if (start <= 0 && nth_power < 0)
{
double s_min = DBL_MAX;
// for the y axis rely on the bounding rects
Expand Down Expand Up @@ -1409,6 +1410,18 @@ void Graph::setAxisScale(int axis, double start, double end, int type, double st
end = 0.01 * start;
}
}
// If n is +ve even integer then negative scale values are not valid
// so set start of axis to 0
if (start < 0 &&
std::floor(nth_power) == nth_power &&
(long)nth_power % 2 == 0)
{
start = 0;
if (end < 0)
{
end = 1;
}
}
}

if (axis == QwtPlot::yRight)
Expand Down

0 comments on commit e736cd7

Please sign in to comment.