1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-10 00:45:36 +00:00

log scale basis in plots

This commit is contained in:
Antonin Portelli 2024-01-12 14:22:23 +01:00
parent 13fddf4947
commit 6739019c83
2 changed files with 9 additions and 5 deletions

View File

@ -515,14 +515,16 @@ void Dash::operator()(PlotOptions &option) const
} }
// LogScale constructor //////////////////////////////////////////////////////// // LogScale constructor ////////////////////////////////////////////////////////
LogScale::LogScale(const Axis axis) LogScale::LogScale(const Axis axis, const double basis)
: axis_(axis) : axis_(axis)
, basis_(basis)
{} {}
// Logscale modifier /////////////////////////////////////////////////////////// // Logscale modifier ///////////////////////////////////////////////////////////
void LogScale::operator()(PlotOptions &option) const void LogScale::operator()(PlotOptions &option) const
{ {
option.scaleMode[static_cast<int>(axis_)] |= Plot::Scale::log; option.scaleMode[static_cast<int>(axis_)] |= Plot::Scale::log;
option.logScaleBasis[static_cast<int>(axis_)] = basis_;
} }
// PlotRange constructors ////////////////////////////////////////////////////// // PlotRange constructors //////////////////////////////////////////////////////
@ -915,11 +917,11 @@ ostream & Latan::operator<<(ostream &out, const Plot &plot)
out << "unset log" << endl; out << "unset log" << endl;
if (plot.options_.scaleMode[x] & Plot::Scale::log) if (plot.options_.scaleMode[x] & Plot::Scale::log)
{ {
out << "set log x" << endl; out << "set log x " << plot.options_.logScaleBasis[x] << endl;;
} }
if (plot.options_.scaleMode[y] & Plot::Scale::log) if (plot.options_.scaleMode[y] & Plot::Scale::log)
{ {
out << "set log y" << endl; out << "set log y " << plot.options_.logScaleBasis[y] << endl;
} }
if (!plot.options_.label[x].empty()) if (!plot.options_.label[x].empty())
{ {

View File

@ -227,6 +227,7 @@ struct PlotOptions
std::string caption; std::string caption;
std::string title; std::string title;
unsigned int scaleMode[2]; unsigned int scaleMode[2];
double logScaleBasis[2];
Range scale[2]; Range scale[2];
std::string label[2]; std::string label[2];
std::string lineColor; std::string lineColor;
@ -314,13 +315,14 @@ class LogScale: public PlotModifier
{ {
public: public:
// constructor // constructor
explicit LogScale(const Axis axis); explicit LogScale(const Axis axis, const double basis = 10);
// destructor // destructor
virtual ~LogScale(void) = default; virtual ~LogScale(void) = default;
// modifier // modifier
virtual void operator()(PlotOptions &option) const; virtual void operator()(PlotOptions &option) const;
private: private:
const Axis axis_; const Axis axis_;
const double basis_;
}; };
class PlotRange: public PlotModifier class PlotRange: public PlotModifier