mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 00:45:36 +00:00
Merge branch 'develop' into feature/feature/reorg
This commit is contained in:
commit
b5e0d5c054
@ -261,6 +261,27 @@ PlotHistogram::PlotHistogram(const Histogram &h)
|
|||||||
setCommand("'" + tmpFileName + "' u 1:2 w steps");
|
setCommand("'" + tmpFileName + "' u 1:2 w steps");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PlotImpulses constructor ////////////////////////////////////////////////////
|
||||||
|
PlotImpulses::PlotImpulses(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 impulses");
|
||||||
|
}
|
||||||
|
|
||||||
// PlotMatrixNoRange constructor ///////////////////////////////////////////////
|
// PlotMatrixNoRange constructor ///////////////////////////////////////////////
|
||||||
PlotMatrixNoRange::PlotMatrixNoRange(const DMat &m)
|
PlotMatrixNoRange::PlotMatrixNoRange(const DMat &m)
|
||||||
{
|
{
|
||||||
@ -371,6 +392,31 @@ void Title::operator()(PlotOptions &option) const
|
|||||||
option.title = title_;
|
option.title = title_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Palette constructor /////////////////////////////////////////////////////////
|
||||||
|
Palette::Palette(const std::vector<std::string> &palette)
|
||||||
|
: palette_(palette)
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Palette modifier ////////////////////////////////////////////////////////////
|
||||||
|
void Palette::operator()(PlotOptions &option) const
|
||||||
|
{
|
||||||
|
option.palette = palette_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// category10 palette //////////////////////////////////////////////////////////
|
||||||
|
const std::vector<std::string> Palette::category10 =
|
||||||
|
{
|
||||||
|
"rgb '#1f77b4'",
|
||||||
|
"rgb '#ff7f0e'",
|
||||||
|
"rgb '#2ca02c'",
|
||||||
|
"rgb '#d62728'",
|
||||||
|
"rgb '#9467bd'",
|
||||||
|
"rgb '#8c564b'",
|
||||||
|
"rgb '#e377c2'",
|
||||||
|
"rgb '#7f7f7f'",
|
||||||
|
"rgb '#bcbd22'"
|
||||||
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Plot implementation *
|
* Plot implementation *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
@ -394,6 +440,7 @@ void Plot::initOptions(void)
|
|||||||
options_.label[0] = "";
|
options_.label[0] = "";
|
||||||
options_.label[1] = "";
|
options_.label[1] = "";
|
||||||
options_.lineColor = "";
|
options_.lineColor = "";
|
||||||
|
options_.palette = Palette::category10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// plot reset //////////////////////////////////////////////////////////////////
|
// plot reset //////////////////////////////////////////////////////////////////
|
||||||
@ -674,6 +721,11 @@ ostream & Latan::operator<<(ostream &out, const Plot &plot)
|
|||||||
{
|
{
|
||||||
out << "set ylabel '" << plot.options_.label[y] << "'" << endl;
|
out << "set ylabel '" << plot.options_.label[y] << "'" << endl;
|
||||||
}
|
}
|
||||||
|
for (unsigned int i = 0; i < plot.options_.palette.size(); ++i)
|
||||||
|
{
|
||||||
|
out << "set linetype " << i + 1 << " lc "
|
||||||
|
<< plot.options_.palette[i] << endl;
|
||||||
|
}
|
||||||
for (unsigned int i = 0; i < plot.headCommand_.size(); ++i)
|
for (unsigned int i = 0; i < plot.headCommand_.size(); ++i)
|
||||||
{
|
{
|
||||||
out << plot.headCommand_[i] << endl;
|
out << plot.headCommand_[i] << endl;
|
||||||
|
@ -146,6 +146,15 @@ public:
|
|||||||
virtual ~PlotHistogram(void) = default;
|
virtual ~PlotHistogram(void) = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PlotImpulses: public PlotObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// constructor
|
||||||
|
PlotImpulses(const DVec &x, const DVec &y);
|
||||||
|
// destructor
|
||||||
|
virtual ~PlotImpulses(void) = default;
|
||||||
|
};
|
||||||
|
|
||||||
class PlotMatrixNoRange: public PlotObject
|
class PlotMatrixNoRange: public PlotObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -180,6 +189,7 @@ struct PlotOptions
|
|||||||
Range scale[2];
|
Range scale[2];
|
||||||
std::string label[2];
|
std::string label[2];
|
||||||
std::string lineColor;
|
std::string lineColor;
|
||||||
|
std::vector<std::string> palette;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlotModifier
|
class PlotModifier
|
||||||
@ -286,6 +296,21 @@ private:
|
|||||||
const std::string title_;
|
const std::string title_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Palette: public PlotModifier
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const std::vector<std::string> category10;
|
||||||
|
public:
|
||||||
|
// constructor
|
||||||
|
explicit Palette(const std::vector<std::string> &palette);
|
||||||
|
// destructor
|
||||||
|
virtual ~Palette(void) = default;
|
||||||
|
// modifier
|
||||||
|
virtual void operator()(PlotOptions &option) const;
|
||||||
|
private:
|
||||||
|
const std::vector<std::string> palette_;
|
||||||
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Plot class *
|
* Plot class *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
@ -111,6 +111,20 @@ double DoubleFunction::operator()(void) const
|
|||||||
return (*this)(nullptr);
|
return (*this)(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<double, double> DoubleFunction::operator()(const std::map<double, double> &m) const
|
||||||
|
{
|
||||||
|
checkSize(1);
|
||||||
|
|
||||||
|
std::map<double, double> res;
|
||||||
|
|
||||||
|
for (auto &val: m)
|
||||||
|
{
|
||||||
|
res[val.first] = (*this)(val.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
// bind ////////////////////////////////////////////////////////////////////////
|
// bind ////////////////////////////////////////////////////////////////////////
|
||||||
DoubleFunction DoubleFunction::bind(const Index argIndex,
|
DoubleFunction DoubleFunction::bind(const Index argIndex,
|
||||||
const double val) const
|
const double val) const
|
||||||
|
@ -52,6 +52,7 @@ public:
|
|||||||
double operator()(void) const;
|
double operator()(void) const;
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
double operator()(const double arg0, const Ts... args) const;
|
double operator()(const double arg0, const Ts... args) const;
|
||||||
|
std::map<double, double> operator()(const std::map<double, double> &m) const;
|
||||||
// bind
|
// bind
|
||||||
DoubleFunction bind(const Index argIndex, const double val) const;
|
DoubleFunction bind(const Index argIndex, const double val) const;
|
||||||
DoubleFunction bind(const Index argIndex, const DVec &x) const;
|
DoubleFunction bind(const Index argIndex, const DVec &x) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user