Skip to content

Commit ee60d08

Browse files
committed
2D grid plot
1 parent 9a27a58 commit ee60d08

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

lib/LatAnalyze/Core/Plot.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,36 @@ PlotImpulses::PlotImpulses(const DVec &x, const DVec &y)
511511
setCommand("'" + tmpFileName + "' u 1:2 w impulses");
512512
}
513513

514+
// PlotGrid constructor ////////////////////////////////////////////////////////
515+
PlotGrid::PlotGrid(const DVec &x, const DVec &y, const DMat &value)
516+
{
517+
if (x.size() != value.rows())
518+
{
519+
LATAN_ERROR(Size, "x vector does not have the same size as value matrix rows");
520+
}
521+
if (y.size() != value.cols())
522+
{
523+
LATAN_ERROR(Size, "y vector does not have the same size as value matrix columns");
524+
}
525+
if (value.rows() < 2 || value.cols() < 2)
526+
{
527+
LATAN_ERROR(Size, "value matrix must have at least 2 rows and 2 columns");
528+
}
529+
DMat d(value.cols()+1, value.rows()+1);
530+
string tmpFileName;
531+
d(0,0) = value.cols();
532+
d.row(0).tail(value.cols()) = x;
533+
d.col(0).tail(value.rows()) = y;
534+
for (Index i = 0; i < value.rows(); ++i)
535+
for (Index j = 0; j < value.cols(); ++j)
536+
{
537+
d(i+1, j+1) = value(j, i);
538+
}
539+
tmpFileName = dumpToTmpFile(d);
540+
pushTmpFile(tmpFileName);
541+
setCommand("'" + tmpFileName + "' nonuniform matrix w image");
542+
}
543+
514544
// PlotMatrixNoRange constructor ///////////////////////////////////////////////
515545
PlotMatrixNoRange::PlotMatrixNoRange(const DMat &m)
516546
{

lib/LatAnalyze/Core/Plot.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,15 @@ class PlotImpulses: public PlotObject
200200
virtual ~PlotImpulses(void) = default;
201201
};
202202

203+
class PlotGrid: public PlotObject
204+
{
205+
public:
206+
// constructor
207+
PlotGrid(const DVec &x, const DVec &y, const DMat &value);
208+
// destructor
209+
virtual ~PlotGrid(void) = default;
210+
};
211+
203212
class PlotMatrixNoRange: public PlotObject
204213
{
205214
public:

0 commit comments

Comments
 (0)