Commit b9a2ace2 authored by Purves, Murray's avatar Purves, Murray
Browse files

#20 Amending cap length on error bars to be relative to axis size

parent 3c0ef274
Pipeline #15638 passed with stages
in 7 minutes and 44 seconds
......@@ -358,7 +358,12 @@ void vtkPlotPointsErrorBars::PaintErrorBars(vtkContext2D *painter,
for (int i = 0; i < n; ++i)
{
float thisX = points[2 * i], thisY = points[2 * i + 1];
float capLength = std::max(0.0, this->GetWidth() / 100.0);
float capLengthX = (this->GetXAxis()->GetMaximum() -
this->GetXAxis()->GetMinimum()) /
100,
capLengthY = (this->GetYAxis()->GetMaximum() -
this->GetYAxis()->GetMinimum()) /
100;
if (XErrors && XErrors->GetNumberOfValues() > i)
{
......@@ -367,11 +372,11 @@ void vtkPlotPointsErrorBars::PaintErrorBars(vtkContext2D *painter,
if (thisError > 0)
{
painter->DrawLine(thisX, thisY, thisX - thisError, thisY);
painter->DrawLine(thisX - thisError, thisY - capLength,
thisX - thisError, thisY + capLength);
painter->DrawLine(thisX - thisError, thisY - capLengthY,
thisX - thisError, thisY + capLengthY);
painter->DrawLine(thisX, thisY, thisX + thisError, thisY);
painter->DrawLine(thisX + thisError, thisY - capLength,
thisX + thisError, thisY + capLength);
painter->DrawLine(thisX + thisError, thisY - capLengthY,
thisX + thisError, thisY + capLengthY);
}
}
if (YErrors && YErrors->GetNumberOfValues() > i)
......@@ -381,11 +386,11 @@ void vtkPlotPointsErrorBars::PaintErrorBars(vtkContext2D *painter,
if (thisError > 0)
{
painter->DrawLine(thisX, thisY, thisX, thisY - thisError);
painter->DrawLine(thisX - capLength, thisY - thisError,
thisX + capLength, thisY - thisError);
painter->DrawLine(thisX - capLengthX, thisY - thisError,
thisX + capLengthX, thisY - thisError);
painter->DrawLine(thisX, thisY, thisX, thisY + thisError);
painter->DrawLine(thisX - capLength, thisY + thisError,
thisX + capLength, thisY + thisError);
painter->DrawLine(thisX - capLengthX, thisY + thisError,
thisX + capLengthX, thisY + thisError);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment