Skip to content

Commit

Permalink
Re #11422 Improve appearance of plot when n is -ve
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew D Jones authored and Matthew D Jones committed Aug 11, 2015
1 parent 8e709db commit be0ea8e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Code/Mantid/MantidPlot/src/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,18 @@ void Graph::setAxisScale(int axis, double start, double end, int type, double st
if (type == GraphOptions::Log10)
{
sc_engine->setType(ScaleTransformation::Log10);
}
else if (type == GraphOptions::Power)
{
sc_engine->setType(ScaleTransformation::Power);
}
else
{
sc_engine->setType(ScaleTransformation::Linear);
}

if (type == GraphOptions::Log10 || type == GraphOptions::Power)
{
if (start <= 0)
{
double s_min = DBL_MAX;
Expand Down Expand Up @@ -1353,14 +1365,6 @@ void Graph::setAxisScale(int axis, double start, double end, int type, double st
// log scales can't represent zero or negative values, 1e-10 is a low number that I hope will be lower than most of the data but is still sensible for many color plots
//start = start < 1e-90 ? 1e-10 : start;
}
else if (type == GraphOptions::Power)
{
sc_engine->setType(ScaleTransformation::Power);
}
else
{
sc_engine->setType(ScaleTransformation::Linear);
}

if (axis == QwtPlot::yRight)
{
Expand Down
10 changes: 10 additions & 0 deletions Code/Mantid/MantidPlot/src/plot2D/PowerScaleEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,16 @@ void PowerScaleEngine::buildTicks(
for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
{
ticks[i] = strip(ticks[i], interval);

// ticks very close to 0.0 are
// explicitly set to 0.0
// important if nth_power is set to -ve value

for ( int j = 0; j < (int)ticks[i].count(); j++ )
{
if ( QwtScaleArithmetic::compareEps(ticks[i][j], 0.0, stepSize) == 0 )
ticks[i][j] = 0.0;
}
}
}

Expand Down

0 comments on commit be0ea8e

Please sign in to comment.