From 1bde8822b1b9b10447229f67aa644a9fee5434eb Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 28 Jan 2020 17:34:00 +0000 Subject: [PATCH] band plot does not rely anymore on tac & tail -r commands --- lib/Core/Plot.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/Core/Plot.cpp b/lib/Core/Plot.cpp index 25d9286..fd695f7 100644 --- a/lib/Core/Plot.cpp +++ b/lib/Core/Plot.cpp @@ -236,14 +236,21 @@ PlotFunction::PlotFunction(const DoubleFunction &function, const double xMin, // PlotPredBand constructor //////////////////////////////////////////////////// void PlotPredBand::makePredBand(const DMat &low, const DMat &high, const double opacity) { - string lowFileName, highFileName; + string lowFileName, highFileName, contFileName; + DMat contour(low.rows() + high.rows() + 1, 2); - lowFileName = dumpToTmpFile(low); - highFileName = dumpToTmpFile(high); - pushTmpFile(lowFileName); - pushTmpFile(highFileName); - setCommand("'< (cat " + lowFileName + "; tac " + highFileName + - "; head -n1 " + lowFileName + ")' u 1:2 w filledcurves closed" + + FOR_MAT(low, i, j) + { + contour(i, j) = low(i, j); + } + FOR_MAT(high, i, j) + { + contour(low.rows() + i, j) = high(high.rows() - i - 1, j); + } + contour.row(low.rows() + high.rows()) = low.row(0); + contFileName = dumpToTmpFile(contour); + pushTmpFile(contFileName); + setCommand("'" + contFileName + "' u 1:2 w filledcurves closed" + " fs solid " + strFrom(opacity) + " noborder"); }