From fef0f3704ccf5736e6da582aa3779b06a25705ac Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Fri, 27 Jun 2025 15:58:36 +0100 Subject: [PATCH] step plot --- lib/LatAnalyze/Core/Plot.cpp | 21 +++++++++++++++++++++ lib/LatAnalyze/Core/Plot.hpp | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/LatAnalyze/Core/Plot.cpp b/lib/LatAnalyze/Core/Plot.cpp index 879c99e..020b170 100644 --- a/lib/LatAnalyze/Core/Plot.cpp +++ b/lib/LatAnalyze/Core/Plot.cpp @@ -511,6 +511,27 @@ PlotImpulses::PlotImpulses(const DVec &x, const DVec &y) setCommand("'" + tmpFileName + "' u 1:2 w impulses"); } +// PlotSteps constructor //////////////////////////////////////////////////// +PlotSteps::PlotSteps(const DVec &x, const DVec &y) +{ + if (x.rows() != y.rows()) + { + LATAN_ERROR(Size, "x and y vector does not have the same size"); + } + + DMat d(x.rows(), 2); + string tmpFileName; + + for (Index i = 0; i < x.rows(); ++i) + { + d(i, 0) = x(i); + d(i, 1) = y(i); + } + tmpFileName = dumpToTmpFile(d); + pushTmpFile(tmpFileName); + setCommand("'" + tmpFileName + "' u 1:2 w steps"); +} + // PlotGrid constructor //////////////////////////////////////////////////////// PlotGrid::PlotGrid(const DVec &x, const DVec &y, const DMat &value) { diff --git a/lib/LatAnalyze/Core/Plot.hpp b/lib/LatAnalyze/Core/Plot.hpp index b12ff96..b0f7e01 100644 --- a/lib/LatAnalyze/Core/Plot.hpp +++ b/lib/LatAnalyze/Core/Plot.hpp @@ -191,6 +191,15 @@ public: virtual ~PlotHistogram(void) = default; }; +class PlotSteps: public PlotObject +{ +public: + // constructor + PlotSteps(const DVec &x, const DVec &y); + // destructor + virtual ~PlotSteps(void) = default; +}; + class PlotImpulses: public PlotObject { public: