diff --git a/pub/plot/dualplot.cpp b/pub/plot/dualplot.cpp index b72ba09e7502b71149ede08a33f8eb1d503774b4..5b1e0c2d6e1e5cfc98f3d375cf75b5e99acd231c 100644 --- a/pub/plot/dualplot.cpp +++ b/pub/plot/dualplot.cpp @@ -24,18 +24,32 @@ using std::cout; CPlot::CPlot(int _iPlot, bool _logx, bool _logy, bool _p2D, bool _logz) : iPlot(_iPlot) - , p2D(_p2D) , X("x", _logx) , Y("y", _logy) - , Z("z", _logz) + , Z("UNUSED", _logz) , maxpoints(20000) , with_errors(true) , equipoints(120) , refine(true) , gnuPlotter(new CGnuPlotter(iPlot)) , ps_Plotter(new CPS_Plotter) -{} +{ + set_dims(_p2D); +} + +//! Sets 1D or 2D; sets axis names accordingly. +void CPlot::set_dims(const bool _p2D) +{ + p2D = _p2D; + if (p2D) { + Y.name = "h"; + Z.name = "y"; + } else { + Y.name = "y"; + Z.name = "UNUSED"; + } +} //! Change one setup parameter per command. @@ -88,11 +102,11 @@ void CPlot::set_aux(const string& cmd) with_errors = false; else if (cmd == "gt") - p2D = !p2D; + set_dims(!p2D); else if (cmd == "gt+") - p2D = true; + set_dims(true); else if (cmd == "gt-") - p2D = false; + set_dims(false); else throw "unknown command " + cmd; diff --git a/pub/plot/dualplot.hpp b/pub/plot/dualplot.hpp index 7ae93ef8a54ac08ad37357e09ff7bd8e2edcace2..9f470fdc1ec1d0001ce3aa5a810cf57f87f63787 100644 --- a/pub/plot/dualplot.hpp +++ b/pub/plot/dualplot.hpp @@ -34,6 +34,9 @@ public: int equipoints; //!< Start curve plot with this # grid points. bool refine; //!< Refine curve plot when appropriate? + void set_dims(const bool _p2D); + void set_aux(const std::string& cmd); + void gp_write(const std::string& in); void start_frame1D( const std::string& caller, const std::string& xlabel, const std::string& ylabel); @@ -53,7 +56,6 @@ public: void write_postscript( const std::string& fname, const std::string& mode, const bool withDefs, std::map<const std::string, std::string>&& settings); - void set_aux(const std::string& cmd); std::string info() const; private: diff --git a/pub/plot/ps_plotter.cpp b/pub/plot/ps_plotter.cpp index a7598d67c5917d84ecf30ced961286f8380e63d5..d2537f3a31ac16c2c909e810e7d98a503673afa0 100644 --- a/pub/plot/ps_plotter.cpp +++ b/pub/plot/ps_plotter.cpp @@ -165,21 +165,25 @@ namespace { ret += "[\n"; if (A->logflag && (Tacks[0] < 1e-3 || Tacks[ntack - 1] > 1e3)) { for (int i = 0; i < ntack; i++) - ret += str(format(" %9.6f {(10)(%i)sp()} %%{(%g)}\n") - % A->pc(Tacks[i]) + ret += str(format(" %g w%s {(10)(%i)sp()} %%{(%g)}\n") + % (float)Tacks[i] + % A->name % (int)(log10(Tacks[i])) % (float)Tacks[i]); } else { for (int i = 0; i < ntack; i++) - ret += str(format(" %9.6f {(%g)}\n") - % A->pc(Tacks[i]) + ret += str(format(" %g w%s {(%g)}\n") + % (float)Tacks[i] + % A->name % (float)Tacks[i]); } ret += " ] SetTacVec\n"; } - ret += str(format("%g %g %i %i SetTicVec%s\n") - % A->pc(ticklim[0]) - % A->pc(ticklim[1]) + ret += str(format("%g w%s %g w%s %i %i SetTicVec%s\n") + % (float)ticklim[0] + % A->name + % (float)ticklim[1] + % A->name % (ntack + 2) % ntpt % (A->logflag ? "Log" : "Lin"));