SNAP Library 2.3, Developer Reference  2014-06-16 11:58:46
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGnuPlot Class Reference

#include <gnuplot.h>

Collaboration diagram for TGnuPlot:

Classes

class  TGpSeries
 
class  TGpSeriesCmp
 

Public Member Functions

TStr GetSeriesPlotStr (const int &PlotN)
 
int IsSameXCol (const int &CurId, const int &PrevId) const
 
void CreatePlotFile (const TStr &Comment=TStr())
 
void RunGnuPlot () const
 
 TGnuPlot (const TStr &FileNm="gplot", const TStr &PlotTitle=TStr(), const bool &Grid=true)
 
 TGnuPlot (const TStr &DataFileNm, const TStr &PlotFileNm, const TStr &PlotTitle, const bool &Grid)
 
 TGnuPlot (const TGnuPlot &GnuPlot)
 
TGnuPlotoperator= (const TGnuPlot &GnuPlot)
 
void SetTitle (const TStr &PlotTitle)
 
void SetXLabel (const TStr &XLabel)
 
void SetYLabel (const TStr &YLabel)
 
void SetXYLabel (const TStr &XLabel, const TStr &YLabel)
 
void SetDataPlotFNm (const TStr &DatFNm, const TStr &PltFNm)
 
void ShowGrid (const bool &Show)
 
void Pause (const bool &DoPause)
 
void SetScale (const TGpScaleTy &GpScaleTy)
 
void SetXRange (const double &Min, const double &Max)
 
void SetYRange (const double &Min, const double &Max)
 
void AddCmd (const TStr &Cmd)
 
TStr GetLineStyle (const int &PlotId) const
 
void SetLineStyle (const int &PlotId, const TStr &StyleStr)
 
int AddFunc (const TStr &FuncStr, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TFltV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TFltV &XValV, const TFltV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TIntPrV &XYValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TFltPrV &XYValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TIntKdV &XYValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TFltKdV &XYValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TIntFltKdV &XYValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TIntFltPrV &XYValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TStr &DataFNm, const int &ColY, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
int AddPlot (const TStr &DataFNm, const int &ColX, const int &ColY, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
 
template<class TKey , class TDat , class THashFunc >
int AddPlot (const THash< TKey, TDat, THashFunc > &XYValH, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr(), const bool &ExpBucket=false)
 
template<class TKey , class THashFunc >
int AddPlot (const THash< TKey, TMom, THashFunc > &ValMomH, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr(), bool PlotAvg=true, bool PlotMed=true, bool PlotMin=false, bool PlotMax=false, bool PlotSDev=false, bool PlotStdErr=false, const bool &ExpBucket=false)
 
int AddErrBar (const TFltTrV &XYDValV, const TStr &Label=TStr())
 
int AddErrBar (const TFltTrV &XYDValV, const TStr &DatLabel, const TStr &ErrLabel)
 
int AddErrBar (const TFltV &YValV, const TFltV &DeltaYV, const TStr &Label=TStr())
 
int AddErrBar (const TFltV &XValV, const TFltV &YValV, const TFltV &DeltaYV, const TStr &Label=TStr())
 
int AddErrBar (const TFltPrV &XYValV, const TFltV &DeltaYV, const TStr &Label=TStr())
 
int AddErrBar (const TFltKdV &XYValV, const TFltV &DeltaYV, const TStr &Label=TStr())
 
int AddErrBar (const TFltPrV &XYValV, const TFltV &DeltaYV, const TStr &DatLabel, const TStr &ErrLabel)
 
int AddLinFit (const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const TStr &Style=TStr())
 
int AddPwrFit (const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const TStr &Style=TStr())
 
int AddPwrFit1 (const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const TStr &Style=TStr())
 
int AddPwrFit2 (const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const double &MinX=-1.0, const TStr &Style=TStr())
 
int AddPwrFit3 (const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const double &MinX=-1.0, const TStr &Style=TStr())
 
int AddPwrFit3 (const int &PlotId, const TGpSeriesTy &SeriesTy, const double &MinX, const TStr &Style, double &Intercept, double &Slope, double &R2)
 
int AddLogFit (const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const TStr &Style=TStr())
 
int AddExpFit (const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const double &FitXOffset=0.0, const TStr &Style=TStr())
 
void SavePng (const int &SizeX=1000, const int &SizeY=800, const TStr &Comment=TStr())
 
void SavePng (const TStr &FNm, const int &SizeX=1000, const int &SizeY=800, const TStr &Comment=TStr(), const TStr &Terminal=TStr())
 
void SaveEps (const int &FontSz=30, const TStr &Comment=TStr())
 
void SaveEps (const TStr &FNm, const int &FontSz=30, const TStr &Comment=TStr())
 
void Plot (const TStr &Comment=TStr())
 

Static Public Member Functions

static int GetTics42 ()
 
static void MakeExpBins (const TFltPrV &XYValV, TFltPrV &ExpXYValV, const double &BinFactor=2, const double &MinYVal=1)
 
static void MakeExpBins (const TFltKdV &XYValV, TFltKdV &ExpXYValV, const double &BinFactor=2, const double &MinYVal=1)
 
static void LoadTs (const TStr &FNm, TStrV &ColNmV, TVec< TFltKdV > &ColV)
 
static TStr GetScaleStr (const TGpScaleTy &ScaleTy)
 
static TStr GetSeriesTyStr (const TGpSeriesTy &SeriesTy)
 
static void SaveTs (const TIntKdV &KdV, const TStr &FNm, const TStr &HeadLn=TStr())
 
static void SaveTs (const TIntFltKdV &KdV, const TStr &FNm, const TStr &HeadLn=TStr())
 
template<class TVal1 , class TVal2 >
static void SaveTs (const TVec< TPair< TVal1, TVal2 > > &ValV, const TStr &FNm, const TStr &HeadLn=TStr())
 
template<class TVal1 , class TVal2 , class TVal3 >
static void SaveTs (const TVec< TTriple< TVal1, TVal2, TVal3 > > &ValV, const TStr &FNm, const TStr &HeadLn=TStr())
 
template<class TVal , int Vals>
static void SaveTs (const TVec< TTuple< TVal, Vals > > &ValV, const TStr &FNm, const TStr &HeadLn=TStr())
 
static void Test ()
 
template<class TVal1 , class TVal2 >
static void PlotValV (const TVec< TPair< TVal1, TVal2 > > &ValV, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const bool &PowerFit=false, const TGpSeriesTy &SeriesTy=gpwLinesPoints)
 
template<class TVal1 , class TVal2 , class TVal3 >
static void PlotValV (const TVec< TTriple< TVal1, TVal2, TVal3 > > &ValV, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const bool &PowerFit=false, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &ErrBarStr="")
 
template<class TVal1 , class TVal2 >
static void PlotValV (const TVec< TPair< TVal1, TVal2 > > &ValV1, const TStr &Name1, const TVec< TPair< TVal1, TVal2 > > &ValV2, const TStr &Name2, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const bool &PowerFit=false, const TGpSeriesTy &SeriesTy=gpwLinesPoints)
 
template<class TVal1 >
static void PlotValV (const TVec< TVal1 > &ValV, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const bool &PowerFit=false, const TGpSeriesTy &SeriesTy=gpwLinesPoints)
 
template<class TKey , class TVal , class THashFunc >
static void PlotValCntH (const THash< TKey, TVal, THashFunc > &ValCntH, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const bool &PowerFit=false, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const bool &PlotNCDF=false, const bool &ExpBucket=false)
 
template<class TKey , class TVal , class THashFunc >
static void PlotValCntH (const THash< TKey, TVal, THashFunc > &ValCntH1, const TStr &Label1, const THash< TKey, TVal, THashFunc > &ValCntH2, const TStr &Label2, const TStr &OutFNmPref, const TStr &Desc, const TStr &XLabel, const TStr &YLabel, const TGpScaleTy &ScaleTy=gpsAuto, const TGpSeriesTy &SeriesTy=gpwLinesPoints)
 
template<class TKey , class TVal , class THashFunc >
static void PlotValCntH (const THash< TKey, TVal, THashFunc > &ValCntH1, const TStr &Label1, const THash< TKey, TVal, THashFunc > &ValCntH2, const TStr &Label2, const THash< TKey, TVal, THashFunc > &ValCntH3, const TStr &Label3, const TStr &OutFNmPref, const TStr &Desc, const TStr &XLabel, const TStr &YLabel, const TGpScaleTy &ScaleTy=gpsAuto, const TGpSeriesTy &SeriesTy=gpwLinesPoints)
 
template<class TVal1 >
static void PlotValMomH (const THash< TVal1, TMom > &ValMomH, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const TGpSeriesTy &SeriesTy=gpwLinesPoints, bool PlotAvg=true, bool PlotMed=true, bool PlotMin=false, bool PlotMax=false, bool PlotSDev=false, bool PlotStdErr=true, bool PlotScatter=false)
 
template<class TVal1 >
static void PlotValMomH (const THash< TVal1, TMom > &ValMomH1, const TStr &Label1, const THash< TVal1, TMom > &ValMomH2, const TStr &Label2, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const TGpSeriesTy &SeriesTy=gpwLinesPoints, bool PlotAvg=true, bool PlotMed=true, bool PlotMin=false, bool PlotMax=false, bool PlotSDev=false, bool PlotStdErr=true, bool PlotScatter=false)
 

Static Public Attributes

static TStr GnuPlotPath = "/usr/bin"
 Path to GnuPlot executable. Set if gnuplot is not found in the PATH. More...
 
static TStr GnuPlotFNm = "gnuplot"
 GnuPlot executable file name. Set if different than the standard wgnuplot/gnuplot. More...
 
static TStr DefPlotFNm = "GnuPlot.plt"
 
static TStr DefDataFNm = "GnuPlot.tab"
 

Private Attributes

TStr DataFNm
 
TStr PlotFNm
 
TStr Title
 
TStr LblX
 
TStr LblY
 
TGpScaleTy ScaleTy
 
TFltPr YRange
 
TFltPr XRange
 
bool SetGrid
 
bool SetPause
 
TVec< TGpSeriesSeriesV
 
TStrV MoreCmds
 

Static Private Attributes

static int Tics42 = -2
 

Detailed Description

Definition at line 16 of file gnuplot.h.

Constructor & Destructor Documentation

TGnuPlot::TGnuPlot ( const TStr FileNm = "gplot",
const TStr PlotTitle = TStr(),
const bool &  Grid = true 
)

Definition at line 86 of file gnuplot.cpp.

References TStr::Empty(), and IAssert.

86  :
87  DataFNm(FileNm+".tab"), PlotFNm(FileNm+".plt"), Title(PlotTitle), LblX(), LblY(), ScaleTy(gpsAuto),
88  YRange(0, 0), XRange(0, 0), SetGrid(Grid), SetPause(true),
89  SeriesV(), MoreCmds() {
90  IAssert(! FileNm.Empty());
91 }
#define IAssert(Cond)
Definition: bd.h:262
TFltPr XRange
Definition: gnuplot.h:53
TStr Title
Definition: gnuplot.h:51
TStr DataFNm
Definition: gnuplot.h:50
TStr LblY
Definition: gnuplot.h:51
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
Definition: gnuplot.h:7
bool SetPause
Definition: gnuplot.h:54
bool SetGrid
Definition: gnuplot.h:54
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
TStr LblX
Definition: gnuplot.h:51
bool Empty() const
Definition: dt.h:488
TFltPr YRange
Definition: gnuplot.h:53
TStr PlotFNm
Definition: gnuplot.h:50
TStrV MoreCmds
Definition: gnuplot.h:56

Here is the call graph for this function:

TGnuPlot::TGnuPlot ( const TStr DataFileNm,
const TStr PlotFileNm,
const TStr PlotTitle,
const bool &  Grid 
)

Definition at line 93 of file gnuplot.cpp.

93  :
94  DataFNm(DataFileNm.Empty() ? DefDataFNm : DataFileNm),
95  PlotFNm(PlotFileNm.Empty() ? DefPlotFNm : PlotFileNm),
96  Title(PlotTitle), LblX(), LblY(), ScaleTy(gpsAuto),
97  YRange(0, 0), XRange(0, 0), SetGrid(Grid), SetPause(true), SeriesV(), MoreCmds() {
98 }
TFltPr XRange
Definition: gnuplot.h:53
TStr Title
Definition: gnuplot.h:51
TStr DataFNm
Definition: gnuplot.h:50
TStr LblY
Definition: gnuplot.h:51
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
Definition: gnuplot.h:7
bool SetPause
Definition: gnuplot.h:54
bool SetGrid
Definition: gnuplot.h:54
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
TStr LblX
Definition: gnuplot.h:51
bool Empty() const
Definition: dt.h:488
static TStr DefDataFNm
Definition: gnuplot.h:23
TFltPr YRange
Definition: gnuplot.h:53
static TStr DefPlotFNm
Definition: gnuplot.h:22
TStr PlotFNm
Definition: gnuplot.h:50
TStrV MoreCmds
Definition: gnuplot.h:56
TGnuPlot::TGnuPlot ( const TGnuPlot GnuPlot)

Definition at line 100 of file gnuplot.cpp.

100  : DataFNm(GnuPlot.DataFNm), PlotFNm(GnuPlot.PlotFNm),
101  Title(GnuPlot.Title), LblX(GnuPlot.LblX), LblY(GnuPlot.LblY), ScaleTy(GnuPlot.ScaleTy), YRange(GnuPlot.YRange),
102  XRange(GnuPlot.XRange), SetGrid(GnuPlot.SetGrid), SetPause(GnuPlot.SetPause), SeriesV(GnuPlot.SeriesV),
103  MoreCmds(GnuPlot.MoreCmds) {
104 }
TFltPr XRange
Definition: gnuplot.h:53
TStr Title
Definition: gnuplot.h:51
TStr DataFNm
Definition: gnuplot.h:50
TStr LblY
Definition: gnuplot.h:51
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
bool SetPause
Definition: gnuplot.h:54
bool SetGrid
Definition: gnuplot.h:54
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
TStr LblX
Definition: gnuplot.h:51
TFltPr YRange
Definition: gnuplot.h:53
TStr PlotFNm
Definition: gnuplot.h:50
TStrV MoreCmds
Definition: gnuplot.h:56

Member Function Documentation

void TGnuPlot::AddCmd ( const TStr Cmd)
inline

Definition at line 81 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), and MoreCmds.

Referenced by TLocClustStat::PlotBestClustDens(), TMAGFitBern::PlotProperties(), PlotValV(), SaveEps(), and SavePng().

81 { MoreCmds.Add(Cmd); }
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
TStrV MoreCmds
Definition: gnuplot.h:56

Here is the call graph for this function:

Here is the caller graph for this function:

int TGnuPlot::AddErrBar ( const TFltTrV XYDValV,
const TStr Label = TStr() 
)

Definition at line 261 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Len().

Referenced by AddErrBar(), AddPlot(), TTimeNet::PlotEffDiam(), TTimeNENet::PlotEffDiam(), PlotValMomH(), PlotValV(), and Test().

261  {
262  TFltKdV XYFltValV(XYDValV.Len(), 0);
263  TFltV DeltaV(XYDValV.Len(), 0);
264  for (int i = 0; i < XYDValV.Len(); i++) {
265  XYFltValV.Add(TFltKd(XYDValV[i].Val1, XYDValV[i].Val2));
266  DeltaV.Add(XYDValV[i].Val3);
267  }
268  return AddErrBar(XYFltValV, DeltaV, Label);
269 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
int AddErrBar(const TFltTrV &XYDValV, const TStr &Label=TStr())
Definition: gnuplot.cpp:261
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

Here is the caller graph for this function:

int TGnuPlot::AddErrBar ( const TFltTrV XYDValV,
const TStr DatLabel,
const TStr ErrLabel 
)

Definition at line 271 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddErrBar(), AddPlot(), gpwLinesPoints, and TVec< TVal, TSizeTy >::Len().

271  {
272  TFltKdV XYFltValV(XYDValV.Len(), 0);
273  TFltV DeltaV(XYDValV.Len(), 0);
274  for (int i = 0; i < XYDValV.Len(); i++) {
275  XYFltValV.Add(TFltKd(XYDValV[i].Val1, XYDValV[i].Val2));
276  DeltaV.Add(XYDValV[i].Val3);
277  }
278  const int PlotId = AddPlot(XYFltValV, gpwLinesPoints, DatLabel);
279  AddErrBar(XYFltValV, DeltaV, ErrLabel);
280  return PlotId;
281 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
int AddErrBar(const TFltTrV &XYDValV, const TStr &Label=TStr())
Definition: gnuplot.cpp:261
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddErrBar ( const TFltV YValV,
const TFltV DeltaYV,
const TStr Label = TStr() 
)

Definition at line 283 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddErrBar(), IAssert, and TVec< TVal, TSizeTy >::Len().

283  {
284  IAssert(YValV.Len() == DeltaYV.Len());
285  TFltKdV XYFltValV(YValV.Len(), 0);
286  for (int i = 0; i < YValV.Len(); i++) {
287  XYFltValV.Add(TFltKd(TFlt(i+1), YValV[i]));
288  }
289  return AddErrBar(XYFltValV, DeltaYV, Label);
290 }
#define IAssert(Cond)
Definition: bd.h:262
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
Definition: dt.h:1289
int AddErrBar(const TFltTrV &XYDValV, const TStr &Label=TStr())
Definition: gnuplot.cpp:261
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddErrBar ( const TFltV XValV,
const TFltV YValV,
const TFltV DeltaYV,
const TStr Label = TStr() 
)

Definition at line 292 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddErrBar(), IAssert, and TVec< TVal, TSizeTy >::Len().

292  {
293  IAssert(XValV.Len() == YValV.Len());
294  IAssert(XValV.Len() == DeltaYV.Len());
295  TFltKdV XYFltValV(XValV.Len(), 0);
296  for (int i = 0; i < XValV.Len(); i++) {
297  XYFltValV.Add(TFltKd(XValV[i], YValV[i]));
298  }
299  return AddErrBar(XYFltValV, DeltaYV, Label);
300 }
#define IAssert(Cond)
Definition: bd.h:262
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
int AddErrBar(const TFltTrV &XYDValV, const TStr &Label=TStr())
Definition: gnuplot.cpp:261
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddErrBar ( const TFltPrV XYValV,
const TFltV DeltaYV,
const TStr Label = TStr() 
)

Definition at line 302 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddErrBar(), and TVec< TVal, TSizeTy >::Len().

302  {
303  TFltKdV XYFltValV(XYValV.Len(), 0);
304  for (int i = 0; i < XYValV.Len(); i++) {
305  XYFltValV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2));
306  }
307  return AddErrBar(XYFltValV, DeltaYV, Label);
308 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
int AddErrBar(const TFltTrV &XYDValV, const TStr &Label=TStr())
Definition: gnuplot.cpp:261
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddErrBar ( const TFltKdV XYValV,
const TFltV DeltaYV,
const TStr Label = TStr() 
)

Definition at line 320 of file gnuplot.cpp.

References TStr::CStr(), DataFNm, TVec< TVal, TSizeTy >::Empty(), gpwErrBars, IAssert, TVec< TVal, TSizeTy >::Len(), Plot(), SeriesV, and Title.

320  {
321  if (XYValV.Empty()) {
322  printf("***AddErrBar: empty plot (%s) %s\n", DataFNm.CStr(), Title.CStr());
323  return -1;
324  }
325  IAssert(XYValV.Len() == DeltaYV.Len());
326  TGpSeries Plot;
327  Plot.SeriesTy = gpwErrBars;
328  Plot.Label = Label;
329  Plot.XYValV = XYValV;
330  Plot.ZValV = DeltaYV;
331  SeriesV.Add(Plot);
332  return SeriesV.Len() - 1;
333 }
#define IAssert(Cond)
Definition: bd.h:262
TStr Title
Definition: gnuplot.h:51
TStr DataFNm
Definition: gnuplot.h:50
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
void Plot(const TStr &Comment=TStr())
Definition: gnuplot.h:126
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:530
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

int TGnuPlot::AddErrBar ( const TFltPrV XYValV,
const TFltV DeltaYV,
const TStr DatLabel,
const TStr ErrLabel 
)

Definition at line 310 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddErrBar(), AddPlot(), gpwLinesPoints, and TVec< TVal, TSizeTy >::Len().

310  {
311  TFltKdV XYFltValV(XYValV.Len(), 0);
312  for (int i = 0; i < XYValV.Len(); i++) {
313  XYFltValV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2));
314  }
315  const int PlotId = AddPlot(XYFltValV, gpwLinesPoints, DatLabel);
316  AddErrBar(XYFltValV, DeltaV, ErrLabel);
317  return PlotId;
318 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
int AddErrBar(const TFltTrV &XYDValV, const TStr &Label=TStr())
Definition: gnuplot.cpp:261
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddExpFit ( const int &  PlotId,
const TGpSeriesTy SeriesTy = gpwLines,
const double &  FitXOffset = 0.0,
const TStr Style = TStr() 
)

!! skip zero values

Definition at line 546 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddFunc(), TStr::Empty(), TVec< TVal, TSizeTy >::Empty(), TSpecFunc::ExpFit(), TStr::Fmt(), TVec< TVal, TSizeTy >::Len(), Plot(), SeriesV, and TGnuPlot::TGpSeries::XYValV.

546  {
547  const TGpSeries& Plot = SeriesV[PlotId];
548  if(Plot.XYValV.Empty()) return -1;
549  const TFltKdV& XY = Plot.XYValV;
550  double A, B, R2, SigA, SigB, Chi2;
551  // power fit
552  TFltPrV XYPr;
553  int s;
554  for (s = 0; s < XY.Len(); s++) {
555  if (XY[s].Key-FitXOffset > 0) {
556  XYPr.Add(TFltPr(XY[s].Key-FitXOffset, XY[s].Dat)); }
557  }
558  TSpecFunc::ExpFit(XYPr, A, B, SigA, SigB, Chi2, R2);
559  TStr Label, StyleStr=Style;
560  if (FitXOffset == 0) { Label = TStr::Fmt("%.4g exp(%.4g x) R^2:%.2g", A, B, R2); }
561  else { Label = TStr::Fmt("%.4g exp(%.4g x - %g) R^2:%.2g", A, B, FitXOffset, R2); }
562  if (StyleStr.Empty()) { StyleStr = "linewidth 3"; }
563  const int FitId = AddFunc(TStr::Fmt("%f*exp(%f*x-%f)", A, B, FitXOffset),
564  SeriesTy, Label, StyleStr);
565  return FitId;
566  /*SeriesV.Add();
567  TGpSeries& NewPlot = SeriesV.Last();
568  TFltKdV& EstXY = NewPlot.XYValV;
569  for (s = 0; s < XYPr.Len(); s++) {
570  EstXY.Add(TFltKd(XYPr[s].Val1+FitXOffset, A*exp(B*XYPr[s].Val1)));
571  }
572  NewPlot.SeriesTy = SeriesTy;
573  if (Style.Empty()) { NewPlot.WithStyle = "linewidth 3"; }
574  else { NewPlot.WithStyle = Style; }
575  return SeriesV.Len() - 1;*/
576 }
static void ExpFit(const TVec< TFltPr > &XY, double &A, double &B, double &SigA, double &SigB, double &Chi2, double &R2)
Definition: xmath.cpp:218
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
void Plot(const TStr &Comment=TStr())
Definition: gnuplot.h:126
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
int AddFunc(const TStr &FuncStr, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:151

Here is the call graph for this function:

int TGnuPlot::AddFunc ( const TStr FuncStr,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 151 of file gnuplot.cpp.

References TStr::CStr(), TGnuPlot::TGpSeries::DataFNm, TStr::Empty(), TStr::Fmt(), TGnuPlot::TGpSeries::Label, Plot(), TGnuPlot::TGpSeries::SeriesTy, SeriesV, TGnuPlot::TGpSeries::WithStyle, and TGnuPlot::TGpSeries::XCol.

Referenced by AddExpFit(), AddLinFit(), AddLogFit(), AddPwrFit1(), AddPwrFit2(), and AddPwrFit3().

151  {
152  const int Id = SeriesV.Len();
153  TGpSeries Plot;
154  Plot.SeriesTy = SeriesTy;
155  Plot.Label = Label;
156  if (! FuncStr.Empty()) { Plot.DataFNm = TStr::Fmt("f%d(x)=%s, f%d(x)", Id, FuncStr.CStr(), Id); }
157  else { Plot.DataFNm = TStr::Fmt("f%d(x)", Id); }
158  Plot.XCol = -1;
159  Plot.WithStyle = Style;
160  SeriesV.Add(Plot);
161  return Id;
162 }
void Plot(const TStr &Comment=TStr())
Definition: gnuplot.h:126
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
bool Empty() const
Definition: dt.h:488
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

Here is the caller graph for this function:

int TGnuPlot::AddLinFit ( const int &  PlotId,
const TGpSeriesTy SeriesTy = gpwLines,
const TStr Style = TStr() 
)

Definition at line 335 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddFunc(), TStr::Empty(), TVec< TVal, TSizeTy >::Empty(), TStr::Fmt(), TVec< TVal, TSizeTy >::Len(), TSpecFunc::LinearFit(), Plot(), SeriesV, and TGnuPlot::TGpSeries::XYValV.

Referenced by Test().

335  {
336  if (PlotId < 0 || PlotId >= SeriesV.Len()) return -1;
337  const TGpSeries& Plot = SeriesV[PlotId];
338  if(Plot.XYValV.Empty()) return -1;
339  const TFltKdV& XY = Plot.XYValV;
340  double A, B, R2, SigA, SigB, Chi2;
341  // linear fit
342  TFltPrV XYPr;
343  int s;
344  for (s = 0; s < XY.Len(); s++) {
345  XYPr.Add(TFltPr(XY[s].Key, XY[s].Dat));
346  }
347  TSpecFunc::LinearFit(XYPr, A, B, SigA, SigB, Chi2, R2);
348  TStr StyleStr=Style;
349  if (StyleStr.Empty()) { StyleStr = "linewidth 3"; }
350  const int FitId = AddFunc(TStr::Fmt("%f+%f*x", A, B),
351  SeriesTy, TStr::Fmt("%.4g + %.4g x R^2:%.2g", A, B, R2), StyleStr);
352  return FitId;
353  /*SeriesV.Add();
354  TGpSeries& NewPlot = SeriesV.Last();
355  TFltKdV& EstXY = NewPlot.XYValV;
356  for (s = 0; s < XY.Len(); s++) {
357  EstXY.Add(TFltKd(XY[s].Key, A + B*XYPr[s].Val1));
358  }
359  NewPlot.Label = TStr::Fmt("%.4g + %.4g x R^2:%.2g", A, B, R2);
360  NewPlot.SeriesTy = SeriesTy;
361  if (Style.Empty()) { NewPlot.WithStyle = "linewidth 3"; }
362  else { NewPlot.WithStyle = Style; }
363  return SeriesV.Len() - 1;*/
364 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
void Plot(const TStr &Comment=TStr())
Definition: gnuplot.h:126
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
static void LinearFit(const TVec< TFltPr > &XY, double &A, double &B, double &SigA, double &SigB, double &Chi2, double &R2)
Definition: xmath.cpp:150
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
int AddFunc(const TStr &FuncStr, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:151

Here is the call graph for this function:

Here is the caller graph for this function:

int TGnuPlot::AddLogFit ( const int &  PlotId,
const TGpSeriesTy SeriesTy = gpwLines,
const TStr Style = TStr() 
)

!! skip zero values

Definition at line 515 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddFunc(), TStr::Empty(), TVec< TVal, TSizeTy >::Empty(), TStr::Fmt(), TVec< TVal, TSizeTy >::Len(), TSpecFunc::LogFit(), Plot(), SeriesV, and TGnuPlot::TGpSeries::XYValV.

515  {
516  const TGpSeries& Plot = SeriesV[PlotId];
517  if(Plot.XYValV.Empty()) return -1;
518  const TFltKdV& XY = Plot.XYValV;
519  double A, B, R2, SigA, SigB, Chi2;
520  // power fit
521  TFltPrV XYPr;
522  int s;
523  for (s = 0; s < XY.Len(); s++) {
524  if (XY[s].Key > 0) {
525  XYPr.Add(TFltPr(XY[s].Key, XY[s].Dat)); }
526  }
527  TSpecFunc::LogFit(XYPr, A, B, SigA, SigB, Chi2, R2);
528  TStr StyleStr=Style;
529  if (StyleStr.Empty()) { StyleStr = "linewidth 3"; }
530  const int FitId = AddFunc(TStr::Fmt("%f+%f*log(x)", A, B),
531  SeriesTy, TStr::Fmt("%.4g + %.4g log(x) R^2:%.2g", A, B, R2), StyleStr);
532  return FitId;
533  /*SeriesV.Add();
534  TGpSeries& NewPlot = SeriesV.Last();
535  TFltKdV& EstXY = NewPlot.XYValV;
536  for (s = 0; s < XYPr.Len(); s++) {
537  EstXY.Add(TFltKd(XYPr[s].Val1, A+B*log((double)XYPr[s].Val1)));
538  }
539  NewPlot.Label = TStr::Fmt("%.4g + %.4g log(x) R^2:%.2g", A, B, R2);
540  NewPlot.SeriesTy = SeriesTy;
541  if (Style.Empty()) { NewPlot.WithStyle = "linewidth 3"; }
542  else { NewPlot.WithStyle = Style; }
543  return SeriesV.Len() - 1;*/
544 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
static void LogFit(const TVec< TFltPr > &XY, double &A, double &B, double &SigA, double &SigB, double &Chi2, double &R2)
Definition: xmath.cpp:208
void Plot(const TStr &Comment=TStr())
Definition: gnuplot.h:126
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
int AddFunc(const TStr &FuncStr, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:151

Here is the call graph for this function:

int TGnuPlot::AddPlot ( const TIntV YValV,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 182 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), and TVec< TVal, TSizeTy >::Len().

Referenced by AddErrBar(), AddPlot(), TNcpGraphsBase::Impose(), TGStatVec::ImposeDistr(), TLocClustStat::ImposeNCP(), TGStat::Plot(), TGStatVec::Plot(), PlotAutoCorrelation(), TLocClustStat::PlotBestClustDens(), TLocClustStat::PlotBoltzmanCurve(), TSnap::PlotClustCf(), TLocClust::PlotCutDistr(), TForestFire::PlotFire(), TFfGGen::PlotFireSize(), PlotGrad(), TSnap::PlotHops(), TLocClustStat::PlotNCP(), TLocClustStat::PlotNCPModul(), TLocClustStat::PlotNCPScatter(), TLocClustStat::PlotNcpTop10(), TLocClust::PlotPhiDistr(), TLocClustStat::PlotPhiInOut(), TMAGFitBern::PlotProperties(), TSnap::PlotSccDistr(), PlotTrueAndEst(), PlotValCntH(), PlotValMomH(), PlotValV(), TLocClust::PlotVolDistr(), TSnap::PlotWccDistr(), TAGMFit::RunMCMC(), TNetInfBs::SaveObjInfo(), Test(), TKroneckerLL::TestBicCriterion(), and TKroneckerLL::TestGradDescent().

182  {
183  TFltKdV XYValV(YValV.Len(), 0);
184  for (int i = 0; i < YValV.Len(); i++) {
185  XYValV.Add(TFltKd(TFlt(i+1), TFlt(YValV[i])));
186  }
187  return AddPlot(XYValV, SeriesTy, Label, Style);
188 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
Definition: dt.h:1289
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

Here is the caller graph for this function:

int TGnuPlot::AddPlot ( const TFltV YValV,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 190 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddPlot(), and TVec< TVal, TSizeTy >::Len().

190  {
191  TFltKdV XYValV(YValV.Len(), 0);
192  for (int i = 0; i < YValV.Len(); i++) {
193  XYValV.Add(TFltKd(TFlt(i+1), TFlt(YValV[i])));
194  }
195  return AddPlot(XYValV, SeriesTy, Label, Style);
196 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
Definition: dt.h:1289
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddPlot ( const TFltV XValV,
const TFltV YValV,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 198 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddPlot(), IAssert, and TVec< TVal, TSizeTy >::Len().

198  {
199  IAssert(XValV.Len() == YValV.Len());
200  TFltKdV XYValV(XValV.Len(), 0);
201  for (int i = 0; i < YValV.Len(); i++) {
202  XYValV.Add(TFltKd(TFlt(XValV[i]), TFlt(YValV[i])));
203  }
204  return AddPlot(XYValV, SeriesTy, Label, Style);
205 }
#define IAssert(Cond)
Definition: bd.h:262
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
Definition: dt.h:1289
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddPlot ( const TIntPrV XYValV,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 207 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddPlot(), and TVec< TVal, TSizeTy >::Len().

207  {
208  TFltKdV XYFltValV(XYValV.Len(), 0);
209  for (int i = 0; i < XYValV.Len(); i++) {
210  XYFltValV.Add(TFltKd(TFlt(XYValV[i].Val1), TFlt(XYValV[i].Val2)));
211  }
212  return AddPlot(XYFltValV, SeriesTy, Label, Style);
213 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
Definition: dt.h:1289
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddPlot ( const TFltPrV XYValV,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 215 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddPlot(), and TVec< TVal, TSizeTy >::Len().

215  {
216  TFltKdV XYFltValV(XYValV.Len(), 0);
217  for (int i = 0; i < XYValV.Len(); i++) {
218  XYFltValV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2));
219  }
220  return AddPlot(XYFltValV, SeriesTy, Label, Style);
221 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddPlot ( const TIntKdV XYValV,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 223 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddPlot(), and TVec< TVal, TSizeTy >::Len().

223  {
224  TFltKdV XYFltValV(XYValV.Len(), 0);
225  for (int i = 0; i < XYValV.Len(); i++) {
226  XYFltValV.Add(TFltKd(TFlt(XYValV[i].Key), TFlt(XYValV[i].Dat)));
227  }
228  return AddPlot(XYFltValV, SeriesTy, Label, Style);
229 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
Definition: dt.h:1289
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddPlot ( const TFltKdV XYValV,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 247 of file gnuplot.cpp.

References TStr::CStr(), DataFNm, TVec< TVal, TSizeTy >::Empty(), TGnuPlot::TGpSeries::Label, Plot(), TGnuPlot::TGpSeries::SeriesTy, SeriesV, Title, TGnuPlot::TGpSeries::WithStyle, and TGnuPlot::TGpSeries::XYValV.

247  {
248  if (XYValV.Empty()) {
249  printf("***AddPlot: empty plot (%s) %s\n", DataFNm.CStr(), Title.CStr());
250  return -1;
251  }
252  TGpSeries Plot;
253  Plot.SeriesTy = SeriesTy;
254  Plot.Label = Label;
255  Plot.XYValV = XYValV;
256  Plot.WithStyle = Style;
257  SeriesV.Add(Plot);
258  return SeriesV.Len() - 1;
259 }
TStr Title
Definition: gnuplot.h:51
TStr DataFNm
Definition: gnuplot.h:50
void Plot(const TStr &Comment=TStr())
Definition: gnuplot.h:126
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:530
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

int TGnuPlot::AddPlot ( const TIntFltKdV XYValV,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 231 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddPlot(), and TVec< TVal, TSizeTy >::Len().

231  {
232  TFltKdV XYFltValV(XYValV.Len(), 0);
233  for (int i = 0; i < XYValV.Len(); i++) {
234  XYFltValV.Add(TFltKd(TFlt(XYValV[i].Key), TFlt(XYValV[i].Dat)));
235  }
236  return AddPlot(XYFltValV, SeriesTy, Label, Style);
237 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
Definition: dt.h:1289
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddPlot ( const TIntFltPrV XYValV,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 239 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddPlot(), and TVec< TVal, TSizeTy >::Len().

239  {
240  TFltKdV XYFltValV(XYValV.Len(), 0);
241  for (int i = 0; i < XYValV.Len(); i++) {
242  XYFltValV.Add(TFltKd(TFlt(XYValV[i].Val1), TFlt(XYValV[i].Val2)));
243  }
244  return AddPlot(XYFltValV, SeriesTy, Label, Style);
245 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
Definition: dt.h:1289
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

int TGnuPlot::AddPlot ( const TStr DataFNm,
const int &  ColY,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 164 of file gnuplot.cpp.

References AddPlot().

165  {
166  return AddPlot(DataFNm, 0, ColY, SeriesTy, Label, Style);
167 }
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182

Here is the call graph for this function:

int TGnuPlot::AddPlot ( const TStr DataFNm,
const int &  ColX,
const int &  ColY,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr() 
)

Definition at line 169 of file gnuplot.cpp.

References TStr::ChangeStrAll(), TGnuPlot::TGpSeries::DataFNm, DataFNm, IAssert, TGnuPlot::TGpSeries::Label, Plot(), TGnuPlot::TGpSeries::SeriesTy, SeriesV, TGnuPlot::TGpSeries::WithStyle, TGnuPlot::TGpSeries::XCol, TGnuPlot::TGpSeries::YCol, and TGnuPlot::TGpSeries::ZCol.

170  {
171  IAssert(ColY > 0); IAssert(ColX >= 0);
172  TGpSeries Plot;
173  Plot.SeriesTy = SeriesTy;
174  Plot.Label = Label;
175  Plot.DataFNm = DataFNm; Plot.DataFNm.ChangeStrAll("\\", "\\\\");
176  Plot.XCol = ColX; Plot.YCol = ColY; Plot.ZCol = 0;
177  Plot.WithStyle = Style;
178  SeriesV.Add(Plot);
179  return SeriesV.Len() - 1;
180 }
#define IAssert(Cond)
Definition: bd.h:262
TStr DataFNm
Definition: gnuplot.h:50
void Plot(const TStr &Comment=TStr())
Definition: gnuplot.h:126
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
int ChangeStrAll(const TStr &SrcStr, const TStr &DstStr, const bool &FromStartP=false)
Definition: dt.cpp:1141

Here is the call graph for this function:

template<class TKey , class TDat , class THashFunc >
int TGnuPlot::AddPlot ( const THash< TKey, TDat, THashFunc > &  XYValH,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr(),
const bool &  ExpBucket = false 
)

Definition at line 249 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), AddPlot(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), THash< TKey, TDat, THashFunc >::GetKey(), THash< TKey, TDat, THashFunc >::Len(), MakeExpBins(), and TVec< TVal, TSizeTy >::Swap().

249  {
250  TFltPrV XYFltValV(XYValH.Len(), 0);
251  for (int k = XYValH.FFirstKeyId(); XYValH.FNextKeyId(k); ) {
252  XYFltValV.Add(TFltPr(TFlt(XYValH.GetKey(k)), TFlt(XYValH[k])));
253  }
254  XYFltValV.Sort();
255  if (ExpBucket) {
256  TFltPrV BucketV;
257  TGnuPlot::MakeExpBins(XYFltValV, BucketV);
258  BucketV.Swap(XYFltValV);
259  }
260  return AddPlot(XYFltValV, SeriesTy, Label, Style);
261 }
static void MakeExpBins(const TFltPrV &XYValV, TFltPrV &ExpXYValV, const double &BinFactor=2, const double &MinYVal=1)
Definition: gnuplot.cpp:609
Definition: dt.h:1289
void Swap(TVec< TVal, TSizeTy > &Vec)
Swaps the contents of the vector with Vec.
Definition: ds.h:1011
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
int FFirstKeyId() const
Definition: hash.h:232
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
int Len() const
Definition: hash.h:186
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210

Here is the call graph for this function:

template<class TKey , class THashFunc >
int TGnuPlot::AddPlot ( const THash< TKey, TMom, THashFunc > &  ValMomH,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr Label = TStr(),
const TStr Style = TStr(),
bool  PlotAvg = true,
bool  PlotMed = true,
bool  PlotMin = false,
bool  PlotMax = false,
bool  PlotSDev = false,
bool  PlotStdErr = false,
const bool &  ExpBucket = false 
)

Definition at line 264 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), AddErrBar(), AddPlot(), TMom::Def(), TVec< TVal, TSizeTy >::Empty(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), THash< TKey, TDat, THashFunc >::GetKey(), TMom::GetMean(), TMom::GetMedian(), TMom::GetMn(), TMom::GetMx(), TMom::GetSDev(), TMom::GetVals(), TMom::IsDef(), MakeExpBins(), TVec< TVal, TSizeTy >::Sort(), and TVec< TVal, TSizeTy >::Swap().

264  {
265  TFltTrV AvgV, StdErrV;
266  TFltPrV AvgV2, MedV, MinV, MaxV, BucketV;
267  for (int i = ValMomH.FFirstKeyId(); ValMomH.FNextKeyId(i); ) {
268  TMom Mom(ValMomH[i]);
269  if (! Mom.IsDef()) { Mom.Def(); }
270  const double x = ValMomH.GetKey(i);
271  if (PlotAvg) {
272  if (PlotSDev) {
273  AvgV.Add(TFltTr(x, Mom.GetMean(), Mom.GetSDev())); } // std deviation
274  else if (PlotStdErr) {
275  StdErrV.Add(TFltTr(x, Mom.GetMean(), Mom.GetSDev()/sqrt((double)Mom.GetVals())));
276  } else {
277  AvgV2.Add(TFltPr(x, Mom.GetMean()));
278  }
279  }
280  if (PlotMed) { MedV.Add(TFltPr(x, Mom.GetMedian())); }
281  if (PlotMin) { MinV.Add(TFltPr(x, Mom.GetMn())); }
282  if (PlotMax) { MaxV.Add(TFltPr(x, Mom.GetMx())); }
283  }
284  AvgV.Sort(); AvgV2.Sort();
285  MedV.Sort(); MinV.Sort(); MaxV.Sort();
286  int PlotId=0;
287  // exponential bucketing
288  if (ExpBucket) {
289  if (! AvgV2.Empty()) { TGnuPlot::MakeExpBins(AvgV2, BucketV); BucketV.Swap(AvgV2); }
290  if (! MedV.Empty()) { TGnuPlot::MakeExpBins(MedV, BucketV); BucketV.Swap(MedV); }
291  if (! MinV.Empty()) { TGnuPlot::MakeExpBins(MinV, BucketV); BucketV.Swap(MinV); }
292  if (! MaxV.Empty()) { TGnuPlot::MakeExpBins(MaxV, BucketV); BucketV.Swap(MaxV); }
293  }
294  // plot
295  if (! AvgV.Empty()) { PlotId = AddErrBar(AvgV, Label+" Average", Label+" StdDev"); }
296  if (! AvgV2.Empty()) { PlotId = AddPlot(AvgV2, SeriesTy, Label+" Average", Style); }
297  if (! MedV.Empty()) { PlotId = AddPlot(MedV, SeriesTy, Label+" Median", Style); }
298  if (! MinV.Empty()) { PlotId = AddPlot(MinV, SeriesTy, Label+" Min", Style); }
299  if (! MaxV.Empty()) { PlotId = AddPlot(MaxV, SeriesTy, Label+" Max", Style); }
300  if (! StdErrV.Empty()) { PlotId = AddErrBar(StdErrV, Label+" Average", Label+" StdErr"); }
301  return PlotId;
302 }
static void MakeExpBins(const TFltPrV &XYValV, TFltPrV &ExpXYValV, const double &BinFactor=2, const double &MinYVal=1)
Definition: gnuplot.cpp:609
Definition: xmath.h:129
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:530
void Swap(TVec< TVal, TSizeTy > &Vec)
Swaps the contents of the vector with Vec.
Definition: ds.h:1011
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1218
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
int FFirstKeyId() const
Definition: hash.h:232
TTriple< TFlt, TFlt, TFlt > TFltTr
Definition: ds.h:175
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
int AddPlot(const TIntV &YValV, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:182
int AddErrBar(const TFltTrV &XYDValV, const TStr &Label=TStr())
Definition: gnuplot.cpp:261
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420

Here is the call graph for this function:

int TGnuPlot::AddPwrFit ( const int &  PlotId,
const TGpSeriesTy SeriesTy = gpwLines,
const TStr Style = TStr() 
)

Definition at line 366 of file gnuplot.cpp.

References AddPwrFit2(), and AddPwrFit3().

Referenced by TGStatVec::ImposeDistr(), TGStat::Plot(), and TGStatVec::Plot().

366  {
367  const int PlotId1 = AddPwrFit3(PlotId, SeriesTy);
368  AddPwrFit2(PlotId, SeriesTy, 5.0);
369  return PlotId1;
370 }
int AddPwrFit3(const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const double &MinX=-1.0, const TStr &Style=TStr())
Definition: gnuplot.cpp:463
int AddPwrFit2(const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const double &MinX=-1.0, const TStr &Style=TStr())
Definition: gnuplot.cpp:415

Here is the call graph for this function:

Here is the caller graph for this function:

int TGnuPlot::AddPwrFit1 ( const int &  PlotId,
const TGpSeriesTy SeriesTy = gpwLines,
const TStr Style = TStr() 
)

!! skip zero values

Definition at line 373 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddFunc(), TStr::Empty(), TVec< TVal, TSizeTy >::Empty(), TStr::Fmt(), TVec< TVal, TSizeTy >::Len(), TMath::Mn(), TFlt::Mx, Plot(), TSpecFunc::PowerFit(), SeriesV, and TGnuPlot::TGpSeries::XYValV.

373  {
374  if (PlotId < 0 || PlotId >= SeriesV.Len()) return -1;
375  const TGpSeries& Plot = SeriesV[PlotId];
376  if(Plot.XYValV.Empty()) return -1;
377  const TFltKdV& XY = Plot.XYValV;
378  double A, B, R2, SigA, SigB, Chi2, MinY = TFlt::Mx, MinX = TFlt::Mx;
379  // power fit
380  TFltPrV XYPr;
381  int s;
382  for (s = 0; s < XY.Len(); s++) {
383  if (XY[s].Key > 0) {
384  XYPr.Add(TFltPr(XY[s].Key, XY[s].Dat));
385  MinX = TMath::Mn(MinX, XY[s].Key());
386  MinY = TMath::Mn(MinY, XY[s].Dat());
387  }
388  }
389  MinY = TMath::Mn(1.0, MinY);
390  TSpecFunc::PowerFit(XYPr, A, B, SigA, SigB, Chi2, R2);
391  TStr StyleStr=Style;
392  if (StyleStr.Empty()) { StyleStr = "linewidth 3"; }
393  const int FitId = AddFunc(TStr::Fmt("%f*x**%f", A, B),
394  SeriesTy, TStr::Fmt("%.1g * x^{%.4g} R^2:%.2g", A, B, R2), StyleStr);
395  return FitId;
396  /*SeriesV.Add();
397  TGpSeries& NewPlot = SeriesV.Last();
398  const int FitId = SeriesV.Len() - 1;
399  NewPlot.DataFNm = ;
400  TFltKdV& EstXY = NewPlot.XYValV;
401  for (s = 0; s < XYPr.Len(); s++) {
402  const double YVal = A*pow(XYPr[s].Val1(), B);
403  if (YVal < MinY) continue;
404  EstXY.Add(TFltKd(XYPr[s].Val1, YVal));
405  }
406  NewPlot.Label = ;
407  NewPlot.SeriesTy = SeriesTy;
408  if (Style.Empty()) { NewPlot.WithStyle = "linewidth 3"; }
409  else { NewPlot.WithStyle = Style; }
410  //if (MinX < 5.0) MinX = 5.0;
411  //AddPwrFit2(PlotId, SeriesTy, MinX);*/
412 }
static const T & Mn(const T &LVal, const T &RVal)
Definition: xmath.h:36
static void PowerFit(const TVec< TFltPr > &XY, double &A, double &B, double &SigA, double &SigB, double &Chi2, double &R2)
Definition: xmath.cpp:193
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
void Plot(const TStr &Comment=TStr())
Definition: gnuplot.h:126
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
static const double Mx
Definition: dt.h:1294
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
int AddFunc(const TStr &FuncStr, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:151

Here is the call graph for this function:

int TGnuPlot::AddPwrFit2 ( const int &  PlotId,
const TGpSeriesTy SeriesTy = gpwLines,
const double &  MinX = -1.0,
const TStr Style = TStr() 
)

Definition at line 415 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddFunc(), TStr::Empty(), TVec< TVal, TSizeTy >::Empty(), TStr::Fmt(), TSpecFunc::GetPowerCoef(), TVec< TVal, TSizeTy >::Len(), TMath::Mn(), TFlt::Mx, Plot(), TSpecFunc::PowerFit(), SeriesV, and TGnuPlot::TGpSeries::XYValV.

Referenced by AddPwrFit().

415  {
416  const TGpSeries& Plot = SeriesV[PlotId];
417  if(Plot.XYValV.Empty()) return -1;
418  const TFltKdV& XY = Plot.XYValV;
419  // power fit
420  TFltPrV XYPr;
421  double MinY = TFlt::Mx;
422  for (int s = 0; s < XY.Len(); s++) {
423  if (XY[s].Key > 0.0) {
424  XYPr.Add(TFltPr(XY[s].Key, XY[s].Dat));
425  MinY = TMath::Mn(MinY, XY[s].Dat());
426  }
427  }
428  if (XYPr.Empty()) return -1;
429  MinY = TMath::Mn(1.0, MinY);
430  // determine the sign of power coefficient
431  double CoefSign = 0.0;
432  { double A, B, R2, SigA, SigB, Chi2;
433  TSpecFunc::PowerFit(XYPr, A, B, SigA, SigB, Chi2, R2);
434  CoefSign = B > 0.0 ? +1.0 : -1.0; }
435  const double PowerCf = CoefSign * TSpecFunc::GetPowerCoef(XYPr, MinX);
436  int Mid = (int) exp(log((double)XYPr.Len())/2.0);
437  if (Mid >= XYPr.Len()) { Mid = XYPr.Len()-1; }
438  const double MidX = XYPr[Mid].Val1();
439  const double MidY = XYPr[Mid].Val2();
440  const double B = MidY / pow(MidX, PowerCf);
441  TStr StyleStr=Style;
442  if (StyleStr.Empty()) { StyleStr = "linewidth 3"; }
443  const int FitId = AddFunc(TStr::Fmt("%f*x**%f", B, PowerCf),
444  SeriesTy, TStr::Fmt("MLE = x^{%.4g}", PowerCf), StyleStr);
445  return FitId;
446  /*SeriesV.Add();
447  TGpSeries& NewPlot = SeriesV.Last();
448  TFltKdV& XYFit = NewPlot.XYValV;
449  XYFit.Gen(XYPr.Len(), 0);
450  for (int s = 0; s < XYPr.Len(); s++) {
451  const double XVal = XYPr[s].Val1;
452  const double YVal = B * pow(XYPr[s].Val1(), PowerCf);
453  if (YVal < MinY || XVal < MinX) continue;
454  XYFit.Add(TFltKd(XVal, YVal));
455  }
456  NewPlot.Label = TStr::Fmt("PowerFit: %g", PowerCf);
457  NewPlot.SeriesTy = SeriesTy;
458  if (Style.Empty()) { NewPlot.WithStyle = "linewidth 3"; }
459  else { NewPlot.WithStyle = Style; }
460  return SeriesV.Len() - 1;*/
461 }
static const T & Mn(const T &LVal, const T &RVal)
Definition: xmath.h:36
static void PowerFit(const TVec< TFltPr > &XY, double &A, double &B, double &SigA, double &SigB, double &Chi2, double &R2)
Definition: xmath.cpp:193
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
void Plot(const TStr &Comment=TStr())
Definition: gnuplot.h:126
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
static const double Mx
Definition: dt.h:1294
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:530
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
static double GetPowerCoef(const TFltV &XValV, double MinX=-1.0)
Definition: xmath.cpp:299
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
int AddFunc(const TStr &FuncStr, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:151

Here is the call graph for this function:

Here is the caller graph for this function:

int TGnuPlot::AddPwrFit3 ( const int &  PlotId,
const TGpSeriesTy SeriesTy = gpwLines,
const double &  MinX = -1.0,
const TStr Style = TStr() 
)

Definition at line 463 of file gnuplot.cpp.

Referenced by AddPwrFit(), and PlotValV().

463  {
464  double Intercept, Slope, R2;
465  return AddPwrFit3(PlotId, SeriesTy, MinX, Style, Intercept, Slope, R2);
466 }
int AddPwrFit3(const int &PlotId, const TGpSeriesTy &SeriesTy=gpwLines, const double &MinX=-1.0, const TStr &Style=TStr())
Definition: gnuplot.cpp:463

Here is the caller graph for this function:

int TGnuPlot::AddPwrFit3 ( const int &  PlotId,
const TGpSeriesTy SeriesTy,
const double &  MinX,
const TStr Style,
double &  Intercept,
double &  Slope,
double &  R2 
)

!! skip zero values

Definition at line 469 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddFunc(), TVec< TVal, TSizeTy >::Clr(), TStr::Empty(), TVec< TVal, TSizeTy >::Empty(), TStr::Fmt(), TVec< TVal, TSizeTy >::Last(), TVec< TVal, TSizeTy >::Len(), TMath::Mn(), TFlt::Mx, Plot(), TSpecFunc::PowerFit(), SeriesV, TVec< TVal, TSizeTy >::Swap(), TPair< TVal1, TVal2 >::Val1, and TGnuPlot::TGpSeries::XYValV.

469  {
470  if (PlotId < 0 || PlotId >= SeriesV.Len()) return -1;
471  const TGpSeries& Plot = SeriesV[PlotId];
472  if(Plot.XYValV.Empty()) return -1;
473  double A, B, SigA, SigB, Chi2, MinY=TFlt::Mx;
474  const TFltKdV& XY = Plot.XYValV;
475  //SeriesV.Add();
476  //TGpSeries& NewPlot = SeriesV.Last();
477  //TFltKdV& EstXY = NewPlot.XYValV;
478  TFltPrV FitXY, NewFitXY;
479  for (int s = 0; s < XY.Len(); s++) {
480  if (XY[s].Key > 0 && XY[s].Key >= MinX) {
481  FitXY.Add(TFltPr(XY[s].Key, XY[s].Dat));
482  MinY = TMath::Mn(MinY, XY[s].Dat());
483  }
484  }
485  MinY = TMath::Mn(1.0, MinY);
486  // power fit (if tail is too fat, cut everything where
487  // extrapolation sets the value < MinY
488  while (true) {
489  TSpecFunc::PowerFit(FitXY, A, B, SigA, SigB, Chi2, R2);
490  NewFitXY.Clr(false);
491  //EstXY.Clr(false);
492  for (int s = 0; s < FitXY.Len(); s++) {
493  const double YVal = A*pow(FitXY[s].Val1(), B);
494  if (YVal < MinY) continue;
495  //EstXY.Add(TFltKd(FitXY[s].Val1, YVal));
496  NewFitXY.Add(TFltPr(FitXY[s].Val1, FitXY[s].Val2));
497  }
498  if (NewFitXY.Len() < 10 || FitXY.Last().Val1 < 1.2 * NewFitXY.Last().Val1) { break; }
499  else { FitXY.Swap(NewFitXY); }
500  }
501  TStr StyleStr=Style;
502  if (StyleStr.Empty()) { StyleStr = "linewidth 3"; }
503  const int FitId = AddFunc(TStr::Fmt("%f*x**%f", A, B),
504  SeriesTy, TStr::Fmt("%.1g * x^{%.4g} R^2:%.2g", A, B, R2), StyleStr);
505  return FitId;
506  /*NewPlot.Label = TStr::Fmt("%.1g * x^{%.4g} R^2:%.2g", A, B, R2);
507  Intercept = A;
508  Slope = B;
509  NewPlot.SeriesTy = SeriesTy;
510  if (Style.Empty()) { NewPlot.WithStyle = "linewidth 3"; }
511  else { NewPlot.WithStyle = Style; }
512  return SeriesV.Len() - 1;*/
513 }
static const T & Mn(const T &LVal, const T &RVal)
Definition: xmath.h:36
static void PowerFit(const TVec< TFltPr > &XY, double &A, double &B, double &SigA, double &SigB, double &Chi2, double &R2)
Definition: xmath.cpp:193
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
void Plot(const TStr &Comment=TStr())
Definition: gnuplot.h:126
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
static const double Mx
Definition: dt.h:1294
void Swap(TVec< TVal, TSizeTy > &Vec)
Swaps the contents of the vector with Vec.
Definition: ds.h:1011
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:953
const TVal & Last() const
Returns a reference to the last element of the vector.
Definition: ds.h:539
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
TVal1 Val1
Definition: ds.h:34
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
int AddFunc(const TStr &FuncStr, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const TStr &Label=TStr(), const TStr &Style=TStr())
Definition: gnuplot.cpp:151

Here is the call graph for this function:

void TGnuPlot::CreatePlotFile ( const TStr Comment = TStr())

Definition at line 763 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), TStr::ChangeStrAll(), TStr::CStr(), TGnuPlot::TGpSeries::DataFNm, DataFNm, EAssertR, TStr::Empty(), TVec< TVal, TSizeTy >::Empty(), TDir::GetCurDir(), GetScaleStr(), GetSeriesPlotStr(), GetTics42(), gpsLog, gpsLog10X, gpsLog10XY, gpsLog10Y, gpsLog2X, gpsLog2XY, gpsLog2Y, IsSameXCol(), TGnuPlot::TGpSeries::Label, LblX, LblY, TVec< TVal, TSizeTy >::Len(), MoreCmds, PlotFNm, TGnuPlot::TGpSeries::SaveXVals(), ScaleTy, SeriesV, SetGrid, SetPause, Tics42, Title, TPair< TVal1, TVal2 >::Val1, TPair< TVal1, TVal2 >::Val2, TGnuPlot::TGpSeries::XCol, XRange, TGnuPlot::TGpSeries::XYValV, TGnuPlot::TGpSeries::YCol, YRange, TGnuPlot::TGpSeries::ZCol, and TGnuPlot::TGpSeries::ZValV.

Referenced by Plot(), SaveEps(), and SavePng().

763  {
764  time_t ltime; time(&ltime);
765  char* TimeStr = ctime(&ltime); TimeStr[strlen(TimeStr) - 1] = 0;
766  // rearrange columns so that longest are on the left
767  //SeriesV.Sort(false);
768  TIntV SerIdV(SeriesV.Len(), 0);
769  for (int i = 0; i < SeriesV.Len(); i++) { SerIdV.Add(i); }
770  SerIdV.SortCmp(TGpSeriesCmp(SeriesV));
771  // set columns
772  int ColCnt = 1;
773  bool SaveData = false;
774  for (int s = 0; s < SeriesV.Len(); s++) {
775  TGpSeries& Plt = SeriesV[SerIdV[s]];
776  if (Plt.XYValV.Empty()) { continue; }
777  Plt.DataFNm = DataFNm;
778  // plots use same X column
779  const int PrevCol = s > 0 ? IsSameXCol(SerIdV[s], SerIdV[s-1]) : -1;
780  if (PrevCol != -1) { Plt.XCol = PrevCol; }
781  else { Plt.XCol = ColCnt; ColCnt++; }
782  Plt.YCol = ColCnt; ColCnt++;
783  if (! Plt.ZValV.Empty()) { Plt.ZCol = ColCnt; ColCnt++; }
784  if (! Plt.XYValV.Empty()) { SaveData=true; }
785  }
786  // save data file (skip duplicate X columns)
787  if (SaveData) {
788  FILE *F = fopen(DataFNm.CStr(), "wt");
789  EAssertR(F != NULL, TStr("Can not open data file ")+DataFNm);
790  fprintf(F, "#\n");
791  fprintf(F, "# %s (%s)\n", Comment.CStr(), TimeStr);
792  fprintf(F, "#\n");
793  // column names
794  for (int i = 0; i < SerIdV.Len(); i++) {
795  const TGpSeries& Ser = SeriesV[SerIdV[i]];
796  if (Ser.XYValV.Empty()) { continue; }
797  if (i == 0) { fprintf(F, "# "); } else { fprintf(F, "\t"); }
798  if (Ser.SaveXVals()) {
799  if (! LblX.Empty()) { fprintf(F, "%s\t", LblX.CStr()); }
800  else { fprintf(F, "XVals\t"); }
801  }
802  if (Ser.Label.Empty()) { fprintf(F, "%s", LblY.CStr()); }
803  else { fprintf(F, "%s", SeriesV[SerIdV[i]].Label.CStr()); }
804  if (Ser.ZCol > 0) fprintf(F, "\tDeltaY");
805  }
806  fprintf(F, "\n");
807  // data
808  for (int row = 0; row < SeriesV[SerIdV[0]].XYValV.Len(); row++) {
809  for (int i = 0; i < SeriesV.Len(); i++) {
810  const TGpSeries& Ser = SeriesV[SerIdV[i]];
811  if (row < Ser.XYValV.Len()) {
812  if (i > 0) { fprintf(F, "\t"); }
813  if (Ser.SaveXVals()) { fprintf(F, "%g\t%g", Ser.XYValV[row].Key(), Ser.XYValV[row].Dat()); }
814  else { fprintf(F, "%g", Ser.XYValV[row].Dat()); }
815  if (! Ser.ZValV.Empty()) { fprintf(F, "\t%g", Ser.ZValV[row]()); }
816  }
817  }
818  fprintf(F, "\n");
819  }
820  fclose(F);
821  }
822  // save plot file
823  FILE *F = fopen(PlotFNm.CStr(), "wt");
824  EAssertR(F != 0, TStr("Can not open plot file ")+PlotFNm);
825  TStr CurDir = TDir::GetCurDir();
826  CurDir.ChangeStrAll("\\", "\\\\");
827  fprintf(F, "#\n");
828  fprintf(F, "# %s (%s)\n", Comment.CStr(), TimeStr);
829  fprintf(F, "#\n\n");
830  if (! Title.Empty()) fprintf(F, "set title \"%s\"\n", Title.CStr());
831  fprintf(F, "set key bottom right\n");
832  fprintf(F, "%s\n", GetScaleStr(ScaleTy).CStr());
834  fprintf(F, "set format x \"10^{%%L}\"\n");
835  fprintf(F, "set mxtics 10\n"); }
837  fprintf(F, "set format y \"10^{%%L}\"\n");
838  fprintf(F, "set mytics 10\n"); }
839  if (ScaleTy==gpsLog2X || ScaleTy==gpsLog2XY) { fprintf(F, "set format x \"2^{%%L}\"\n"); }
840  if (ScaleTy==gpsLog2Y || ScaleTy==gpsLog2XY) { fprintf(F, "set format y \"2^{%%L}\"\n"); }
841  if (SetGrid) fprintf(F, "set grid\n");
842  if (XRange.Val1 != XRange.Val2) fprintf(F, "set xrange [%g:%g]\n", XRange.Val1(), XRange.Val2());
843  if (YRange.Val1 != YRange.Val2) fprintf(F, "set yrange [%g:%g]\n", YRange.Val1(), YRange.Val2());
844  if (! LblX.Empty()) fprintf(F, "set xlabel \"%s\"\n", LblX.CStr());
845  if (! LblY.Empty()) fprintf(F, "set ylabel \"%s\"\n", LblY.CStr());
846  if (Tics42 < -1) {
847  Tics42 = GetTics42();
848  }
849  if (Tics42) {
850  fprintf(F, "set tics scale 2\n"); // New in version 4.2
851  } else {
852  fprintf(F, "set ticscale 2 1\n"); // Old (deprecated)
853  }
854  // custom commands
855  for (int i = 0; i < MoreCmds.Len(); i++) {
856  fprintf(F, "%s\n", MoreCmds[i].CStr()); }
857  // plot
858  if (! SeriesV.Empty()) {
859  fprintf(F, "plot \t");
860  for (int i = 0; i < SeriesV.Len(); i++) {
861  fprintf(F, "%s", GetSeriesPlotStr(i).CStr()); }
862  fprintf(F, "\n");
863  }
864  if (SetPause) fprintf(F, "pause -1 \"Hit return to exit. %s\"\n", PlotFNm.CStr());
865  fclose(F);
866 }
static TStr GetCurDir()
Definition: xfl.cpp:233
TFltPr XRange
Definition: gnuplot.h:53
TStr Title
Definition: gnuplot.h:51
TStr DataFNm
Definition: gnuplot.h:50
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
static int GetTics42()
Definition: gnuplot.cpp:26
TStr LblY
Definition: gnuplot.h:51
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
int ChangeStrAll(const TStr &SrcStr, const TStr &DstStr, const bool &FromStartP=false)
Definition: dt.cpp:1141
Definition: gnuplot.h:7
bool SetPause
Definition: gnuplot.h:54
bool SetGrid
Definition: gnuplot.h:54
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
TStr LblX
Definition: gnuplot.h:51
int IsSameXCol(const int &CurId, const int &PrevId) const
Definition: gnuplot.cpp:753
Definition: dt.h:412
bool Empty() const
Definition: dt.h:488
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
TFltPr YRange
Definition: gnuplot.h:53
TVal1 Val1
Definition: ds.h:34
TVal2 Val2
Definition: ds.h:35
static TStr GetScaleStr(const TGpScaleTy &ScaleTy)
Definition: gnuplot.cpp:678
char * CStr()
Definition: dt.h:476
TStr GetSeriesPlotStr(const int &PlotN)
Definition: gnuplot.cpp:124
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
TStr PlotFNm
Definition: gnuplot.h:50
static int Tics42
Definition: gnuplot.h:48
TStrV MoreCmds
Definition: gnuplot.h:56

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TGnuPlot::GetLineStyle ( const int &  PlotId) const
inline

Definition at line 82 of file gnuplot.h.

References SeriesV.

82 { return SeriesV[PlotId].WithStyle; }
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
TStr TGnuPlot::GetScaleStr ( const TGpScaleTy ScaleTy)
static

Definition at line 678 of file gnuplot.cpp.

References Fail, gpsAuto, gpsLog, gpsLog10X, gpsLog10XY, gpsLog10Y, gpsLog2X, gpsLog2XY, gpsLog2Y, and gpsNoAuto.

Referenced by CreatePlotFile().

678  {
679  switch(ScaleTy){
680  case gpsNoAuto: return TStr("set noautoscale");
681  case gpsAuto: return TStr("set autoscale");
682  case gpsLog: return TStr("set logscale");
683  case gpsLog2X: return TStr("set logscale x 2");
684  case gpsLog2Y: return TStr("set logscale y 2");
685  case gpsLog2XY: return TStr("set logscale xy 2");
686  case gpsLog10X: return TStr("set logscale x 10");
687  case gpsLog10Y: return TStr("set logscale y 10");
688  case gpsLog10XY: return TStr("set logscale xy 10");
689  default: Fail;
690  }
691  return TStr();
692 }
#define Fail
Definition: bd.h:238
Definition: gnuplot.h:7
Definition: gnuplot.h:7
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
Definition: dt.h:412

Here is the caller graph for this function:

TStr TGnuPlot::GetSeriesPlotStr ( const int &  PlotN)

Definition at line 124 of file gnuplot.cpp.

References TGnuPlot::TGpSeries::DataFNm, TStr::Empty(), GetSeriesTyStr(), TInt::GetStr(), gpwBoxes, gpwFilledCurves, gpwLines, gpwLinesPoints, gpwPoints, TGnuPlot::TGpSeries::Label, TGnuPlot::TGpSeries::SeriesTy, SeriesV, TGnuPlot::TGpSeries::WithStyle, TGnuPlot::TGpSeries::XCol, TGnuPlot::TGpSeries::YCol, and TGnuPlot::TGpSeries::ZCol.

Referenced by CreatePlotFile().

124  {
125  TChA PlotStr;
126  TGpSeries& Series = SeriesV[SeriesId];
127  if (SeriesId != 0) PlotStr += ",\\\n\t";
128  if (Series.XCol >= 0) {
129  PlotStr += "\"" + Series.DataFNm + "\" using " + TInt::GetStr(Series.XCol);
130  if (Series.YCol != 0) { PlotStr += ":" + TInt::GetStr(Series.YCol); }
131  if (Series.ZCol != 0) { PlotStr += ":" + TInt::GetStr(Series.ZCol); }
132  else if (Series.SeriesTy==gpwFilledCurves) { PlotStr += ":(0)"; } // filled curves requres 3rd column
133  } else {
134  // function
135  //IAssertR(Series.DataFNm.SearchCh('=') != -1, TStr::Fmt("Expression %s is not a function", Series.DataFNm.CStr()));
136  PlotStr += Series.DataFNm;
137  }
138  PlotStr += " title \"" + Series.Label + "\"";
139  // hard coded line style
140  if (Series.WithStyle.Empty()) {
141  if (Series.SeriesTy == gpwLines) Series.WithStyle = "lw 1";
142  if (Series.SeriesTy == gpwPoints) Series.WithStyle = "pt 6"; // circles
143  if (Series.SeriesTy == gpwLinesPoints) Series.WithStyle = "pt 6"; // circles
144  if (Series.SeriesTy == gpwBoxes) Series.WithStyle = "fill solid 0.3";
145  }
146  PlotStr += " with " + GetSeriesTyStr(Series.SeriesTy) + " " + Series.WithStyle;
147  return PlotStr;
148 }
TStr GetStr() const
Definition: dt.h:1104
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
static TStr GetSeriesTyStr(const TGpSeriesTy &SeriesTy)
Definition: gnuplot.cpp:694
Definition: dt.h:201

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TGnuPlot::GetSeriesTyStr ( const TGpSeriesTy SeriesTy)
static

Definition at line 694 of file gnuplot.cpp.

References Fail, gpwBoxes, gpwDots, gpwErrBars, gpwFilledCurves, gpwFSteps, gpwHiSteps, gpwImpulses, gpwLines, gpwLinesPoints, gpwPoints, and gpwSteps.

Referenced by GetSeriesPlotStr().

694  {
695  switch(SeriesTy) {
696  case gpwLines: return TStr("lines");
697  case gpwPoints: return TStr("points");
698  case gpwLinesPoints: return TStr("linespoints");
699  case gpwImpulses: return TStr("impulses");
700  case gpwDots: return TStr("dots");
701  case gpwSteps: return TStr("steps");
702  case gpwFSteps: return TStr("fsteps");
703  case gpwHiSteps: return TStr("histeps");
704  case gpwBoxes: return TStr("boxes");
705  case gpwErrBars: return TStr("errorbars");
706  case gpwFilledCurves: return TStr("filledcurves");
707  default: Fail;
708  }
709  return TStr();
710 }
#define Fail
Definition: bd.h:238
Definition: dt.h:412

Here is the caller graph for this function:

int TGnuPlot::GetTics42 ( )
static

Definition at line 26 of file gnuplot.cpp.

References TStr::Fmt().

Referenced by CreatePlotFile().

26  {
27 #ifdef GLib_WIN
28  return -1;
29 #else
30  FILE* p;
31  char Buf[1024];
32  char Version[1024];
33  size_t n;
34 
35  // get gnuplot version
36  p = popen(TStr::Fmt("%s -V", TGnuPlot::GnuPlotFNm.CStr()).CStr(), "r");
37  if (p == NULL) { // try running using the path
38  p = popen(TStr::Fmt("%s/%s -V", TGnuPlot::GnuPlotPath.CStr(), TGnuPlot::GnuPlotFNm.CStr()).CStr(), "r");
39  if (p == NULL) { return -1; }
40  }
41  n = fread(Buf, 1, 100, p);
42  if (n <= 0) { return -1; }
43  Buf[n] = '\0';
44  pclose(p);
45  //printf("Buf %d .%s.\n", n, Buf);
46  n = sscanf(Buf, "gnuplot %s", Version);
47  if (n <= 0) { return -1; }
48  // printf("Version %d .%s.\n", n, Version);
49  if ((strlen(Version) < 3) || (Version[1] != '.')) { return -1; }
50  // test version < 4.2
51  if ((Version[0] < '4') || ((Version[0] == '4') && (Version[2] < '2'))) {
52  // printf("TGnuPlot::GetTics42 0\n");
53  return 0;
54  }
55  // printf("TGnuPlot::GetTics42 1\n");
56  return 1;
57 #endif
58 }
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
static TStr GnuPlotPath
Path to GnuPlot executable. Set if gnuplot is not found in the PATH.
Definition: gnuplot.h:19
static TStr GnuPlotFNm
GnuPlot executable file name. Set if different than the standard wgnuplot/gnuplot.
Definition: gnuplot.h:21

Here is the call graph for this function:

Here is the caller graph for this function:

int TGnuPlot::IsSameXCol ( const int &  CurId,
const int &  PrevId 
) const

Definition at line 753 of file gnuplot.cpp.

References IAssert, and SeriesV.

Referenced by CreatePlotFile().

753  {
754  //if (SerId < 1) { return -1; }
755  if (SeriesV[CurId].XYValV.Len() != SeriesV[PrevId].XYValV.Len()) { return -1; }
756  for (int x = 0; x < SeriesV[CurId].XYValV.Len(); x++) {
757  if (SeriesV[CurId].XYValV[x] != SeriesV[PrevId].XYValV[x]) { return -1; }
758  }
759  IAssert(SeriesV[PrevId].XCol > 0);
760  return SeriesV[PrevId].XCol;
761 }
#define IAssert(Cond)
Definition: bd.h:262
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55

Here is the caller graph for this function:

void TGnuPlot::LoadTs ( const TStr FNm,
TStrV ColNmV,
TVec< TFltKdV > &  ColV 
)
static

Definition at line 660 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Clr(), TPt< TRec >::Empty(), TVec< TVal, TSizeTy >::Gen(), TVec< TVal, TSizeTy >::Len(), TSs::LoadTxt(), and ssfTabSep.

660  {
661  PSs Ss = TSs::LoadTxt(ssfTabSep, FNm);
662  int row = 0;
663  ColNmV.Clr();
664  while (Ss->At(0, row)[0] == '#') { row++; }
665  for (int c = 1; c < Ss->GetXLen(row); c+=2) {
666  ColNmV.Add(Ss->At(c, row));
667  }
668  row++;
669  ColV.Gen(ColNmV.Len(), ColNmV.Len());
670  for (; row < Ss->GetYLen(); row++) {
671  for (int c = 0; c < Ss->GetXLen(row); c+=2) {
672  if (Ss->At(c,row).Empty()) break;
673  ColV[c/2].Add(TFltKd(Ss->At(c,row).GetFlt(), Ss->At(c+1,row).GetFlt()));
674  }
675  }
676 }
static PSs LoadTxt(const TSsFmt &SsFmt, const TStr &FNm, const PNotify &Notify=NULL, const bool &IsExcelEoln=true, const int &MxY=-1, const TIntV &AllowedColNV=TIntV(), const bool &IsQStr=true)
Definition: ss.cpp:100
bool Empty() const
Definition: bd.h:501
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:953
Tab separated.
Definition: ss.h:6
Definition: bd.h:196
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

void TGnuPlot::MakeExpBins ( const TFltPrV XYValV,
TFltPrV ExpXYValV,
const double &  BinFactor = 2,
const double &  MinYVal = 1 
)
static

Definition at line 609 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Gen(), and TVec< TVal, TSizeTy >::Len().

Referenced by AddPlot(), TGStatVec::ImposeDistr(), TGUtil::MakeExpBins(), and PlotValCntH().

609  {
610  TFltKdV KdV(XYValV.Len(), 0), OutV;
611  for (int i = 0; i < XYValV.Len(); i++) {
612  KdV.Add(TFltKd(XYValV[i].Val1, XYValV[i].Val2)); }
613  KdV.Sort();
614  TGnuPlot::MakeExpBins(KdV, OutV, BinFactor, MinYVal);
615  ExpXYValV.Gen(OutV.Len(), 0);
616  for (int i = 0; i < OutV.Len(); i++) {
617  ExpXYValV.Add(TFltPr(OutV[i].Key, OutV[i].Dat)); }
618 }
static void MakeExpBins(const TFltPrV &XYValV, TFltPrV &ExpXYValV, const double &BinFactor=2, const double &MinYVal=1)
Definition: gnuplot.cpp:609
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559

Here is the call graph for this function:

Here is the caller graph for this function:

void TGnuPlot::MakeExpBins ( const TFltKdV XYValV,
TFltKdV ExpXYValV,
const double &  BinFactor = 2,
const double &  MinYVal = 1 
)
static

Definition at line 620 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), TVec< TVal, TSizeTy >::Clr(), TVec< TVal, TSizeTy >::Empty(), TVec< TVal, TSizeTy >::Gen(), IAssert, TVec< TVal, TSizeTy >::IsSorted(), TKeyDat< TKey, TDat >::Key, TVec< TVal, TSizeTy >::Last(), and TVec< TVal, TSizeTy >::Len().

620  {
621  if (XYValV.Empty()) { ExpXYValV.Clr(false); return; }
622  IAssert(! XYValV.Empty());
623  IAssert(XYValV.IsSorted());
624  const TFlt MxX = XYValV.Last().Key;
625  // find buckets
626  TFltV BucketEndV; BucketEndV.Add(1);
627  double PrevBPos = 1, BPos = 1;
628  while (BPos <= MxX) {
629  PrevBPos = (uint) floor(BPos);
630  BPos *= BinFactor;
631  if (floor(BPos) == PrevBPos) {
632  BPos = PrevBPos + 1; }
633  BucketEndV.Add(floor(BPos));
634  }
635  //printf("buckets:\n"); for (int i = 0; i < BucketEndV.Len(); i++) { printf("\t%g\n", BucketEndV[i]);}
636  ExpXYValV.Gen(BucketEndV.Len(), 0);
637  int CurB = 0;
638  double AvgPos=0, Cnt=0, AvgVal=0;
639  for (int v = 0; v < XYValV.Len(); v++) {
640  if (XYValV[v].Key() == 0.0) { continue; }
641  AvgPos += XYValV[v].Key ;//* XYValV[v].Dat; // x
642  AvgVal += XYValV[v].Dat; // y
643  Cnt++;
644  if (v+1 == XYValV.Len() || XYValV[v+1].Key > BucketEndV[CurB]) {
645  if (Cnt != 0) {
646  //AvgPos /= AvgVal;
647  //AvgVal /= (BucketEndV[CurB]-BucketEndV[CurB-1]);
648  AvgPos /= (double) Cnt;
649  AvgVal /= (double) Cnt;
650  if (AvgVal < MinYVal) { AvgVal = MinYVal; }
651  ExpXYValV.Add(TFltKd(AvgPos, AvgVal));
652  //printf("b: %6.2f\t%6.2f\n", AvgPos, AvgVal);
653  AvgPos = 0; AvgVal = 0; Cnt = 0;
654  }
655  CurB++;
656  }
657  }
658 }
#define IAssert(Cond)
Definition: bd.h:262
unsigned int uint
Definition: bd.h:11
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
Definition: dt.h:1289
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:530
void Clr(const bool &DoDel=true, const TSizeTy &NoDelLim=-1)
Clears the contents of the vector.
Definition: ds.h:953
const TVal & Last() const
Returns a reference to the last element of the vector.
Definition: ds.h:539
TKey Key
Definition: ds.h:338
bool IsSorted(const bool &Asc=true) const
Checks whether the vector is sorted in ascending (if Asc=true) or descending (if Asc=false) order...
Definition: ds.h:1223
void Gen(const TSizeTy &_Vals)
Constructs a vector (an array) of _Vals elements.
Definition: ds.h:486
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420

Here is the call graph for this function:

TGnuPlot & TGnuPlot::operator= ( const TGnuPlot GnuPlot)

Definition at line 106 of file gnuplot.cpp.

References DataFNm, LblX, LblY, MoreCmds, PlotFNm, ScaleTy, SeriesV, SetGrid, SetPause, Title, XRange, and YRange.

106  {
107  if (this != &GnuPlot) {
108  DataFNm = GnuPlot.DataFNm;
109  PlotFNm = GnuPlot.PlotFNm;
110  Title = GnuPlot.Title;
111  LblX = GnuPlot.LblX;
112  LblY = GnuPlot.LblY;
113  ScaleTy = GnuPlot.ScaleTy;
114  YRange = GnuPlot.YRange;
115  XRange = GnuPlot.XRange;
116  SetGrid = GnuPlot.SetGrid;
117  SetPause = GnuPlot.SetPause;
118  SeriesV = GnuPlot.SeriesV;
119  MoreCmds = GnuPlot.MoreCmds;
120  }
121  return *this;
122 }
TFltPr XRange
Definition: gnuplot.h:53
TStr Title
Definition: gnuplot.h:51
TStr DataFNm
Definition: gnuplot.h:50
TStr LblY
Definition: gnuplot.h:51
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
bool SetPause
Definition: gnuplot.h:54
bool SetGrid
Definition: gnuplot.h:54
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
TStr LblX
Definition: gnuplot.h:51
TFltPr YRange
Definition: gnuplot.h:53
TStr PlotFNm
Definition: gnuplot.h:50
TStrV MoreCmds
Definition: gnuplot.h:56
void TGnuPlot::Pause ( const bool &  DoPause)
inline

Definition at line 77 of file gnuplot.h.

References SetPause.

Referenced by SaveEps(), and SavePng().

77 { SetPause = DoPause; }
bool SetPause
Definition: gnuplot.h:54

Here is the caller graph for this function:

void TGnuPlot::Plot ( const TStr Comment = TStr())
inline

Definition at line 126 of file gnuplot.h.

References CreatePlotFile(), and RunGnuPlot().

Referenced by AddErrBar(), AddExpFit(), AddFunc(), AddLinFit(), AddLogFit(), AddPlot(), AddPwrFit1(), AddPwrFit2(), AddPwrFit3(), and Test().

126 { CreatePlotFile(Comment); RunGnuPlot(); }
void RunGnuPlot() const
Definition: gnuplot.cpp:868
void CreatePlotFile(const TStr &Comment=TStr())
Definition: gnuplot.cpp:763

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey , class TVal , class THashFunc >
void TGnuPlot::PlotValCntH ( const THash< TKey, TVal, THashFunc > &  ValCntH,
const TStr OutFNmPref,
const TStr Desc = "",
const TStr XLabel = "",
const TStr YLabel = "",
const TGpScaleTy ScaleTy = gpsAuto,
const bool &  PowerFit = false,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const bool &  PlotNCDF = false,
const bool &  ExpBucket = false 
)
static

Definition at line 306 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), THash< TKey, TDat, THashFunc >::GetKey(), THash< TKey, TDat, THashFunc >::Len(), TVec< TVal, TSizeTy >::Len(), MakeExpBins(), and PlotValV().

Referenced by TLocClust::DrawWhiskers(), TLocClustStat::PlotBoltzmanCurve(), TLocClustStat::PlotPhiDistr(), and PlotValCntH().

308  {
309  TFltPrV IdCntV(ValCntH.Len(), 0), BucketV;
310  for (int i = ValCntH.FFirstKeyId(); ValCntH.FNextKeyId(i); ) {
311  IdCntV.Add(TFltPr(double(ValCntH.GetKey(i)), double(ValCntH[i]))); }
312  IdCntV.Sort();
313  if (ExpBucket) {
314  TGnuPlot::MakeExpBins(IdCntV, BucketV);
315  BucketV.Swap(IdCntV);
316  }
317  if (PlotNCDF) {
318  TFltPrV NCdfV = IdCntV;
319  for (int i = NCdfV.Len()-2; i >= 0; i--) {
320  NCdfV[i].Val2 = NCdfV[i].Val2 + NCdfV[i+1].Val2;
321  }
322  PlotValV(NCdfV, OutFNmPref, Desc, "NCDF "+XLabel, "NCDF "+YLabel, ScaleTy, PowerFit, SeriesTy);
323  } else {
324  PlotValV(IdCntV, OutFNmPref, Desc, XLabel, YLabel, ScaleTy, PowerFit, SeriesTy);
325  }
326 }
static void MakeExpBins(const TFltPrV &XYValV, TFltPrV &ExpXYValV, const double &BinFactor=2, const double &MinYVal=1)
Definition: gnuplot.cpp:609
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
int FFirstKeyId() const
Definition: hash.h:232
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
static void PlotValV(const TVec< TPair< TVal1, TVal2 > > &ValV, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const bool &PowerFit=false, const TGpSeriesTy &SeriesTy=gpwLinesPoints)
Definition: gnuplot.h:363
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
int Len() const
Definition: hash.h:186
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TKey , class TVal , class THashFunc >
void TGnuPlot::PlotValCntH ( const THash< TKey, TVal, THashFunc > &  ValCntH1,
const TStr Label1,
const THash< TKey, TVal, THashFunc > &  ValCntH2,
const TStr Label2,
const TStr OutFNmPref,
const TStr Desc,
const TStr XLabel,
const TStr YLabel,
const TGpScaleTy ScaleTy = gpsAuto,
const TGpSeriesTy SeriesTy = gpwLinesPoints 
)
static

Definition at line 329 of file gnuplot.h.

References PlotValCntH().

332  {
333  PlotValCntH(ValCntH1, Label1, ValCntH2, Label2, THash<TKey, TVal, THashFunc>(), "", OutFNmPref, Desc, XLabel, YLabel,
334  ScaleTy, SeriesTy);
335 }
static void PlotValCntH(const THash< TKey, TVal, THashFunc > &ValCntH, const TStr &OutFNmPref, const TStr &Desc="", const TStr &XLabel="", const TStr &YLabel="", const TGpScaleTy &ScaleTy=gpsAuto, const bool &PowerFit=false, const TGpSeriesTy &SeriesTy=gpwLinesPoints, const bool &PlotNCDF=false, const bool &ExpBucket=false)
Definition: gnuplot.h:306
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
Definition: hash.h:88

Here is the call graph for this function:

template<class TKey , class TVal , class THashFunc >
void TGnuPlot::PlotValCntH ( const THash< TKey, TVal, THashFunc > &  ValCntH1,
const TStr Label1,
const THash< TKey, TVal, THashFunc > &  ValCntH2,
const TStr Label2,
const THash< TKey, TVal, THashFunc > &  ValCntH3,
const TStr Label3,
const TStr OutFNmPref,
const TStr Desc,
const TStr XLabel,
const TStr YLabel,
const TGpScaleTy ScaleTy = gpsAuto,
const TGpSeriesTy SeriesTy = gpwLinesPoints 
)
static

Definition at line 338 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), AddPlot(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), THash< TKey, TDat, THashFunc >::GetKey(), THash< TKey, TDat, THashFunc >::Len(), SavePng(), SetScale(), and SetXYLabel().

342  {
343  TFltPrV IdCntV1(ValCntH1.Len(), 0), IdCntV2(ValCntH2.Len(), 0), IdCntV3(ValCntH3.Len(), 0);
344  for (int i = ValCntH1.FFirstKeyId(); ValCntH1.FNextKeyId(i); ) {
345  IdCntV1.Add(TFltPr(double(ValCntH1.GetKey(i)), double(ValCntH1[i]))); }
346  for (int i = ValCntH2.FFirstKeyId(); ValCntH2.FNextKeyId(i); ) {
347  IdCntV2.Add(TFltPr(double(ValCntH2.GetKey(i)), double(ValCntH2[i]))); }
348  for (int i = ValCntH3.FFirstKeyId(); ValCntH3.FNextKeyId(i); ) {
349  IdCntV3.Add(TFltPr(double(ValCntH3.GetKey(i)), double(ValCntH3[i]))); }
350  IdCntV1.Sort();
351  IdCntV2.Sort();
352  IdCntV3.Sort();
353  TGnuPlot GP(OutFNmPref, Desc);
354  GP.SetXYLabel(XLabel, YLabel);
355  GP.SetScale(ScaleTy);
356  if (! IdCntV1.Empty()) { GP.AddPlot(IdCntV1, SeriesTy, Label1); }
357  if (! IdCntV2.Empty()) { GP.AddPlot(IdCntV2, SeriesTy, Label2); }
358  if (! IdCntV3.Empty()) { GP.AddPlot(IdCntV3, SeriesTy, Label3); }
359  GP.SavePng();
360 }
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
int FFirstKeyId() const
Definition: hash.h:232
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
int Len() const
Definition: hash.h:186
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210

Here is the call graph for this function:

template<class TVal1 >
void TGnuPlot::PlotValMomH ( const THash< TVal1, TMom > &  ValMomH,
const TStr OutFNmPref,
const TStr Desc = "",
const TStr XLabel = "",
const TStr YLabel = "",
const TGpScaleTy ScaleTy = gpsAuto,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
bool  PlotAvg = true,
bool  PlotMed = true,
bool  PlotMin = false,
bool  PlotMax = false,
bool  PlotSDev = false,
bool  PlotStdErr = true,
bool  PlotScatter = false 
)
static

Definition at line 468 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), AddErrBar(), THashSet< TKey, THashFunc >::AddKey(), AddPlot(), TMom::Def(), TVec< TVal, TSizeTy >::Empty(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), THash< TKey, TDat, THashFunc >::GetKey(), TMom::GetMean(), TMom::GetMedian(), TMom::GetMn(), TMom::GetMx(), TMom::GetSDev(), TMom::GetVals(), gpwPoints, TMom::IsDef(), THashSet< TKey, THashFunc >::Len(), SavePng(), SetScale(), SetXYLabel(), and TVec< TVal, TSizeTy >::Sort().

Referenced by TNcpGraphsBase::PlotAvgNcp().

470  {
471  TFltTrV AvgV, StdErrV;
472  TFltPrV AvgV2, MedV, MinV, MaxV;
473  TFltPrV ScatterV;
474  for (int i = ValMomH.FFirstKeyId(); ValMomH.FNextKeyId(i); ) {
475  TMom Mom(ValMomH[i]);
476  if (! Mom.IsDef()) { Mom.Def(); }
477  const double x = ValMomH.GetKey(i);
478  if (PlotAvg) {
479  if (PlotSDev) {
480  AvgV.Add(TFltTr(x, Mom.GetMean(), Mom.GetSDev())); } // std deviation
481  else {
482  AvgV2.Add(TFltPr(x, Mom.GetMean()));
483  }
484  if (PlotStdErr) {
485  StdErrV.Add(TFltTr(x, Mom.GetMean(), Mom.GetSDev()/sqrt((double)Mom.GetVals())));
486  }
487  }
488  if (PlotMed) { MedV.Add(TFltPr(x, Mom.GetMedian())); }
489  if (PlotMin) { MinV.Add(TFltPr(x, Mom.GetMn())); }
490  if (PlotMax) { MaxV.Add(TFltPr(x, Mom.GetMx())); }
491  if (PlotScatter) {
492  THashSet<TFlt> PointSet;
493  for (int xi = 0; xi < ValMomH[i].GetVals(); xi++) {
494  PointSet.AddKey(ValMomH[i].GetVal(xi)); }
495  //ScatterV.Add(TFltPr(x, ValMomH[i].GetVal(xi))); }
496  for (int xi = 0; xi < PointSet.Len(); xi++) {
497  ScatterV.Add(TFltPr(x, PointSet[xi])); }
498  //printf("S%d %d %d.", ValMomH[i].GetVals(), PointSet.Len(), ScatterV.Len());
499  }
500  }
501  AvgV.Sort(); AvgV2.Sort();
502  MedV.Sort(); MinV.Sort(); MaxV.Sort(); StdErrV.Sort();
503  TGnuPlot GP(OutFNmPref, Desc);
504  GP.SetScale(ScaleTy);
505  GP.SetXYLabel(XLabel, YLabel);
506  if (! ScatterV.Empty()) { GP.AddPlot(ScatterV, gpwPoints, "Scatter"); }
507  if (! AvgV.Empty()) { GP.AddErrBar(AvgV, "Average", "StdDev"); }
508  if (! AvgV2.Empty()) { GP.AddPlot(AvgV2, SeriesTy, "Average"); }
509  if (! MedV.Empty()) { GP.AddPlot(MedV, SeriesTy, "Median"); }
510  if (! MinV.Empty()) { GP.AddPlot(MinV, SeriesTy, "Min"); }
511  if (! MaxV.Empty()) { GP.AddPlot(MaxV, SeriesTy, "Max"); }
512  if (! StdErrV.Empty()) { GP.AddErrBar(StdErrV, "Standard error"); }
513  GP.SavePng();
514 }
Definition: xmath.h:129
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:530
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1218
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
int AddKey(const TKey &Key)
Definition: shash.h:1248
int FFirstKeyId() const
Definition: hash.h:232
TTriple< TFlt, TFlt, TFlt > TFltTr
Definition: ds.h:175
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
int Len() const
Definition: shash.h:1115
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal1 >
void TGnuPlot::PlotValMomH ( const THash< TVal1, TMom > &  ValMomH1,
const TStr Label1,
const THash< TVal1, TMom > &  ValMomH2,
const TStr Label2,
const TStr OutFNmPref,
const TStr Desc = "",
const TStr XLabel = "",
const TStr YLabel = "",
const TGpScaleTy ScaleTy = gpsAuto,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
bool  PlotAvg = true,
bool  PlotMed = true,
bool  PlotMin = false,
bool  PlotMax = false,
bool  PlotSDev = false,
bool  PlotStdErr = true,
bool  PlotScatter = false 
)
static

Definition at line 517 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), AddErrBar(), THashSet< TKey, THashFunc >::AddKey(), AddPlot(), TMom::Def(), TVec< TVal, TSizeTy >::Empty(), THash< TKey, TDat, THashFunc >::FFirstKeyId(), THash< TKey, TDat, THashFunc >::FNextKeyId(), THash< TKey, TDat, THashFunc >::GetKey(), TMom::GetMean(), TMom::GetMedian(), TMom::GetMn(), TMom::GetMx(), TMom::GetSDev(), TMom::GetVals(), gpwPoints, TMom::IsDef(), THashSet< TKey, THashFunc >::Len(), SavePng(), SetScale(), SetXYLabel(), and TVec< TVal, TSizeTy >::Sort().

519  {
520  TFltTrV AvgV1, AvgV2, StdErrV1, StdErrV2;
521  TFltPrV AvgVM1, MedV1, MinV1, MaxV1;
522  TFltPrV AvgVM2, MedV2, MinV2, MaxV2;
523  TFltPrV ScatterV1, ScatterV2;
524  // ValMom1
525  for (int i = ValMomH1.FFirstKeyId(); ValMomH1.FNextKeyId(i); ) {
526  TMom Mom(ValMomH1[i]);
527  if (! Mom.IsDef()) { Mom.Def(); }
528  const double x = ValMomH1.GetKey(i);
529  if (PlotAvg) {
530  if (PlotSDev) {
531  AvgV1.Add(TFltTr(x, Mom.GetMean(), Mom.GetSDev())); } // std deviation
532  else {
533  AvgVM1.Add(TFltPr(x, Mom.GetMean()));
534  }
535  if (PlotStdErr) {
536  StdErrV1.Add(TFltTr(x, Mom.GetMean(), Mom.GetSDev()/sqrt((double)Mom.GetVals())));
537  }
538  }
539  if (PlotMed) { MedV1.Add(TFltPr(x, Mom.GetMedian())); }
540  if (PlotMin) { MinV1.Add(TFltPr(x, Mom.GetMn())); }
541  if (PlotMax) { MaxV1.Add(TFltPr(x, Mom.GetMx())); }
542  if (PlotScatter) {
543  THashSet<TFlt> PointSet;
544  for (int xi = 0; xi < ValMomH1[i].GetVals(); xi++) {
545  PointSet.AddKey(ValMomH1[i].GetVal(xi)); }
546  for (int xi = 0; xi < PointSet.Len(); xi++) {
547  ScatterV1.Add(TFltPr(x, PointSet[xi])); }
548  }
549  }
550  AvgV1.Sort(); AvgVM1.Sort(); MedV1.Sort(); MinV1.Sort(); MaxV1.Sort(); StdErrV1.Sort();
551  // ValMom2
552  for (int i = ValMomH2.FFirstKeyId(); ValMomH2.FNextKeyId(i); ) {
553  TMom Mom(ValMomH2[i]);
554  if (! Mom.IsDef()) { Mom.Def(); }
555  const double x = ValMomH2.GetKey(i);
556  if (PlotAvg) {
557  if (PlotSDev) {
558  AvgV2.Add(TFltTr(x, Mom.GetMean(), Mom.GetSDev())); } // std deviation
559  else {
560  AvgVM2.Add(TFltPr(x, Mom.GetMean()));
561  }
562  if (PlotStdErr) {
563  StdErrV2.Add(TFltTr(x, Mom.GetMean(), Mom.GetSDev()/sqrt((double)Mom.GetVals())));
564  }
565  }
566  if (PlotMed) { MedV2.Add(TFltPr(x, Mom.GetMedian())); }
567  if (PlotMin) { MinV2.Add(TFltPr(x, Mom.GetMn())); }
568  if (PlotMax) { MaxV2.Add(TFltPr(x, Mom.GetMx())); }
569  if (PlotScatter) {
570  THashSet<TFlt> PointSet;
571  for (int xi = 0; xi < ValMomH2[i].GetVals(); xi++) {
572  PointSet.AddKey(ValMomH2[i].GetVal(xi)); }
573  for (int xi = 0; xi < PointSet.Len(); xi++) {
574  ScatterV2.Add(TFltPr(x, PointSet[xi])); }
575  }
576  }
577  AvgV2.Sort(); AvgVM2.Sort(); MedV2.Sort(); MinV2.Sort(); MaxV2.Sort(); StdErrV2.Sort();
578  // plot
579  TGnuPlot GP(OutFNmPref, Desc);
580  GP.SetScale(ScaleTy);
581  GP.SetXYLabel(XLabel, YLabel);
582  // ValMom1
583  if (! ScatterV1.Empty()) { GP.AddPlot(ScatterV1, gpwPoints, Label1+": Scatter"); }
584  if (! AvgV1.Empty()) { GP.AddErrBar(AvgV1, Label1+": Average", Label1+": StdDev"); }
585  if (! AvgVM1.Empty()) { GP.AddPlot(AvgVM1, SeriesTy, Label1+": Average"); }
586  if (! MedV1.Empty()) { GP.AddPlot(MedV1, SeriesTy, Label1+": Median"); }
587  if (! MinV1.Empty()) { GP.AddPlot(MinV1, SeriesTy, Label1+": Min"); }
588  if (! MaxV1.Empty()) { GP.AddPlot(MaxV1, SeriesTy, Label1+": Max"); }
589  if (! StdErrV1.Empty()) { GP.AddErrBar(StdErrV1, Label1+": Std error"); }
590  // ValMom2
591  if (! ScatterV2.Empty()) { GP.AddPlot(ScatterV2, gpwPoints, Label2+": Scatter"); }
592  if (! AvgV2.Empty()) { GP.AddErrBar(AvgV2, Label2+": Average", Label2+": StdDev"); }
593  if (! AvgVM2.Empty()) { GP.AddPlot(AvgVM2, SeriesTy, Label2+": Average"); }
594  if (! MedV2.Empty()) { GP.AddPlot(MedV2, SeriesTy, Label2+": Median"); }
595  if (! MinV2.Empty()) { GP.AddPlot(MinV2, SeriesTy, Label2+": Min"); }
596  if (! MaxV2.Empty()) { GP.AddPlot(MaxV2, SeriesTy, Label2+": Max"); }
597  if (! StdErrV2.Empty()) { GP.AddErrBar(StdErrV2, Label2+": Std error"); }
598  GP.SavePng();
599 }
Definition: xmath.h:129
bool Empty() const
Tests whether the vector is empty.
Definition: ds.h:530
void Sort(const bool &Asc=true)
Sorts the elements of the vector.
Definition: ds.h:1218
bool FNextKeyId(int &KeyId) const
Definition: hash.h:432
int AddKey(const TKey &Key)
Definition: shash.h:1248
int FFirstKeyId() const
Definition: hash.h:232
TTriple< TFlt, TFlt, TFlt > TFltTr
Definition: ds.h:175
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
int Len() const
Definition: shash.h:1115
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
const TKey & GetKey(const int &KeyId) const
Definition: hash.h:210
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420

Here is the call graph for this function:

template<class TVal1 , class TVal2 >
void TGnuPlot::PlotValV ( const TVec< TPair< TVal1, TVal2 > > &  ValV,
const TStr OutFNmPref,
const TStr Desc = "",
const TStr XLabel = "",
const TStr YLabel = "",
const TGpScaleTy ScaleTy = gpsAuto,
const bool &  PowerFit = false,
const TGpSeriesTy SeriesTy = gpwLinesPoints 
)
static

Definition at line 363 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), AddCmd(), AddPlot(), AddPwrFit3(), TStr::CStr(), TStr::Fmt(), SavePng(), SetScale(), SetXYLabel(), and Swap().

Referenced by TKroneckerLL::ChainGelmapRubinPlot(), TCesna::FindComs(), TAGMFast::FindComsByCV(), TCoda::FindComsByCV(), TAGMFast::MLEGradAscent(), TCoda::MLEGradAscent(), TCesna::MLEGradAscent(), TAGMFit::MLEGradAscentGivenCAG(), TAGMFast::MLEGradAscentParallel(), TCoda::MLEGradAscentParallel(), TCesna::MLEGradAscentParallel(), TLogRegFit::MLEGradient(), TAGMFast::MLENewton(), TNcpGraphsBase::PlotBestWhisker(), TLocClustStat::PlotBoltzmanCurve(), TTimeNet::PlotCCfOverTm(), TSnap::PlotEigValDistr(), TSnap::PlotEigValRank(), TSnap::PlotInDegDistr(), TSnap::PlotInvParticipRat(), TSnap::PlotKCoreEdges(), TSnap::PlotKCoreNodes(), TTimeNet::PlotMedianDegOverTm(), TNcpGraphsBase::PlotNcpMin(), TSnap::PlotOutDegDistr(), TNcpGraphsBase::PlotRewBestWhisker(), TNcpGraphsBase::PlotRewNcpMin(), TSnap::PlotShortPathDistr(), TSnap::PlotSngValDistr(), TSnap::PlotSngValRank(), TSnap::PlotSngVec(), and PlotValCntH().

364  {
365  TFltKdV IdCntV(ValV.Len(), 0);
366  for (int i = 0; i < ValV.Len(); i++) {
367  IdCntV.Add(TFltKd(double(ValV[i].Val1), double(ValV[i].Val2))); }
368  if (IdCntV.Empty()) { printf("*** Empty plot %s\n", OutFNmPref.CStr()); return; }
369  IdCntV.Sort();
370  TGnuPlot GP(OutFNmPref, Desc);
371  GP.SetXYLabel(XLabel, YLabel);
372  GP.SetScale(ScaleTy);
373  const int Id = GP.AddPlot(IdCntV, SeriesTy);
374  if (PowerFit) {
375  GP.AddPwrFit3(Id);
376  double MaxY = IdCntV.Last().Dat, MinY = IdCntV[0].Dat;
377  if (MaxY < MinY) { Swap(MaxY, MinY); }
378  //GP.SetYRange(MinY, pow(10.0, floor(log10(MaxY))+1.0));
379  GP.AddCmd(TStr::Fmt("set yrange[%f:]", MinY));
380  }
381  GP.SavePng();
382 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void Swap(TRec &Rec1, TRec &Rec2)
Definition: bd.h:568

Here is the call graph for this function:

Here is the caller graph for this function:

template<class TVal1 , class TVal2 , class TVal3 >
void TGnuPlot::PlotValV ( const TVec< TTriple< TVal1, TVal2, TVal3 > > &  ValV,
const TStr OutFNmPref,
const TStr Desc = "",
const TStr XLabel = "",
const TStr YLabel = "",
const TGpScaleTy ScaleTy = gpsAuto,
const bool &  PowerFit = false,
const TGpSeriesTy SeriesTy = gpwLinesPoints,
const TStr ErrBarStr = "" 
)
static

Definition at line 385 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), AddCmd(), AddErrBar(), AddPlot(), AddPwrFit3(), TStr::CStr(), TStr::Fmt(), SavePng(), SetScale(), SetXYLabel(), and Swap().

386  {
387  TFltKdV IdCntV(ValV.Len(), 0);
388  TFltV DeltaYV(ValV.Len(), 0);
389  for (int i = 0; i < ValV.Len(); i++) {
390  IdCntV.Add(TFltKd(double(ValV[i].Val1), double(ValV[i].Val2)));
391  DeltaYV.Add(double(ValV[i].Val3));
392  }
393  if (IdCntV.Empty()) { printf("*** Empty plot %s\n", OutFNmPref.CStr()); return; }
394  IdCntV.Sort();
395  TGnuPlot GP(OutFNmPref, Desc);
396  GP.SetXYLabel(XLabel, YLabel);
397  GP.SetScale(ScaleTy);
398  const int Id = GP.AddPlot(IdCntV, SeriesTy);
399  GP.AddErrBar(IdCntV, DeltaYV, ErrBarStr);
400  if (PowerFit) {
401  GP.AddPwrFit3(Id);
402  double MaxY = IdCntV.Last().Dat, MinY = IdCntV[0].Dat;
403  if (MaxY < MinY) { Swap(MaxY, MinY); }
404  //GP.SetYRange(MinY, pow(10.0, floor(log10(MaxY))+1.0));
405  GP.AddCmd(TStr::Fmt("set yrange[%f:]", MinY));
406  }
407  GP.SavePng();
408 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void Swap(TRec &Rec1, TRec &Rec2)
Definition: bd.h:568

Here is the call graph for this function:

template<class TVal1 , class TVal2 >
void TGnuPlot::PlotValV ( const TVec< TPair< TVal1, TVal2 > > &  ValV1,
const TStr Name1,
const TVec< TPair< TVal1, TVal2 > > &  ValV2,
const TStr Name2,
const TStr OutFNmPref,
const TStr Desc = "",
const TStr XLabel = "",
const TStr YLabel = "",
const TGpScaleTy ScaleTy = gpsAuto,
const bool &  PowerFit = false,
const TGpSeriesTy SeriesTy = gpwLinesPoints 
)
static

Definition at line 412 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), AddCmd(), AddPlot(), AddPwrFit3(), TStr::CStr(), TStr::Fmt(), SavePng(), SetScale(), SetXYLabel(), and Swap().

414  {
415  TFltKdV IdCntV1(ValV1.Len(), 0), IdCntV2(ValV2.Len(), 0);
416  for (int i = 0; i < ValV1.Len(); i++) {
417  IdCntV1.Add(TFltKd(double(ValV1[i].Val1), double(ValV1[i].Val2))); }
418  for (int i = 0; i < ValV2.Len(); i++) {
419  IdCntV2.Add(TFltKd(double(ValV2[i].Val1), double(ValV2[i].Val2))); }
420  if (IdCntV1.Empty() || IdCntV2.Empty()) { printf("*** Empty plot %s\n", OutFNmPref.CStr()); return; }
421  IdCntV1.Sort();
422  IdCntV2.Sort();
423  TGnuPlot GP(OutFNmPref, Desc);
424  GP.SetXYLabel(XLabel, YLabel);
425  GP.SetScale(ScaleTy);
426  { const int Id = GP.AddPlot(IdCntV1, SeriesTy, Name1);
427  if (PowerFit) {
428  GP.AddPwrFit3(Id);
429  double MaxY = IdCntV1.Last().Dat, MinY = IdCntV1[0].Dat;
430  if (MaxY < MinY) { Swap(MaxY, MinY); }
431  GP.AddCmd(TStr::Fmt("set yrange[%f:]", MinY));
432  } }
433  { const int Id = GP.AddPlot(IdCntV2, SeriesTy, Name2);
434  if (PowerFit) {
435  GP.AddPwrFit3(Id);
436  double MaxY = IdCntV2.Last().Dat, MinY = IdCntV2[0].Dat;
437  if (MaxY < MinY) { Swap(MaxY, MinY); }
438  GP.AddCmd(TStr::Fmt("set yrange[%f:]", MinY));
439  } }
440  GP.SavePng();
441 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void Swap(TRec &Rec1, TRec &Rec2)
Definition: bd.h:568

Here is the call graph for this function:

template<class TVal1 >
void TGnuPlot::PlotValV ( const TVec< TVal1 > &  ValV,
const TStr OutFNmPref,
const TStr Desc = "",
const TStr XLabel = "",
const TStr YLabel = "",
const TGpScaleTy ScaleTy = gpsAuto,
const bool &  PowerFit = false,
const TGpSeriesTy SeriesTy = gpwLinesPoints 
)
static

Definition at line 446 of file gnuplot.h.

References TVec< TVal, TSizeTy >::Add(), AddCmd(), AddPlot(), AddPwrFit3(), TStr::CStr(), TStr::Fmt(), TVec< TVal, TSizeTy >::Len(), SavePng(), SetScale(), SetXYLabel(), and Swap().

447  {
448  TFltKdV IdCntV(ValV.Len(), 0);
449  for (int i = 0; i < ValV.Len(); i++) {
450  IdCntV.Add(TFltKd(double(i+1), double(ValV[i]))); }
451  if (IdCntV.Empty()) { printf("*** Empty plot %s\n", OutFNmPref.CStr()); return; }
452  IdCntV.Sort();
453  TGnuPlot GP(OutFNmPref, Desc);
454  GP.SetXYLabel(XLabel, YLabel);
455  GP.SetScale(ScaleTy);
456  const int Id = GP.AddPlot(IdCntV, SeriesTy);
457  if (PowerFit) {
458  GP.AddPwrFit3(Id);
459  double MaxY = IdCntV.Last().Dat, MinY = IdCntV[0].Dat;
460  if (MaxY < MinY) { Swap(MaxY, MinY); }
461  //GP.SetYRange(MinY, pow(10.0, floor(log10(MaxY))+1.0));
462  GP.AddCmd(TStr::Fmt("set yrange[%f:]", MinY));
463  }
464  GP.SavePng();
465 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
TKeyDat< TFlt, TFlt > TFltKd
Definition: ds.h:386
TGpScaleTy ScaleTy
Definition: gnuplot.h:52
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
void Swap(TRec &Rec1, TRec &Rec2)
Definition: bd.h:568

Here is the call graph for this function:

void TGnuPlot::RunGnuPlot ( ) const

Definition at line 868 of file gnuplot.cpp.

References TStr::CStr(), TStr::Empty(), TStr::Fmt(), GnuPlotFNm, GnuPlotPath, and PlotFNm.

Referenced by Plot(), TLocClustStat::PlotBestClustDens(), SaveEps(), and SavePng().

868  {
869  // try running gnuplot
870  if (system(TStr::Fmt("%s %s", GnuPlotFNm.CStr(), PlotFNm.CStr()).CStr())==0) { return; }
871  if (! GnuPlotPath.Empty()) {
872  #if defined(GLib_WIN)
873  if (system(TStr::Fmt("%s\\%s %s", GnuPlotPath.CStr(), GnuPlotFNm.CStr(), PlotFNm.CStr()).CStr())==0) { return; }
874  #else
875  if (system(TStr::Fmt("%s/%s %s", GnuPlotPath.CStr(), GnuPlotFNm.CStr(), PlotFNm.CStr()).CStr())==0) { return; }
876  #endif
877  }
878  //Old
879  //#if defined(GLib_WIN)
880  //if (system(TStr::Fmt(".\\%s %s", GpFNm.CStr(), PlotFNm.CStr()).CStr())==0) { return; }
881  //#else
882  //if (system(TStr::Fmt("./%s %s", GpFNm.CStr(), PlotFNm.CStr()).CStr())==0) { return; }
883  //#endif
884  //if (system(TStr::Fmt("%s%s %s", GpPath.CStr(), GpFNm.CStr(), PlotFNm.CStr()).CStr())==0) { return; }
885  //FailR(TStr::Fmt("Cannot find GnuPlot (%s) for plot %s. Set the PATH.", GpFNm.CStr(), PlotFNm.CStr()).CStr());
886  //ErrNotify(TStr::Fmt("Cannot find GnuPlot (%s) for plot %s. Set the PATH.", GpFNm.CStr(), PlotFNm.CStr()).CStr());
887  fprintf(stderr, "[%s:%d] Cannot find GnuPlot (%s) for plot %s. Set the $$PATH variable or TGnuPlot::GnuPlotPath. (%s)\n", __FILE__, __LINE__, GnuPlotFNm.CStr(), PlotFNm.CStr(), TGnuPlot::GnuPlotPath.CStr());
888 }
bool Empty() const
Definition: dt.h:488
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
static TStr GnuPlotPath
Path to GnuPlot executable. Set if gnuplot is not found in the PATH.
Definition: gnuplot.h:19
char * CStr()
Definition: dt.h:476
static TStr GnuPlotFNm
GnuPlot executable file name. Set if different than the standard wgnuplot/gnuplot.
Definition: gnuplot.h:21
TStr PlotFNm
Definition: gnuplot.h:50

Here is the call graph for this function:

Here is the caller graph for this function:

void TGnuPlot::SaveEps ( const int &  FontSz = 30,
const TStr Comment = TStr() 
)
inline

Definition at line 123 of file gnuplot.h.

References TStr::GetFMid(), TStr::GetFPath(), and PlotFNm.

Referenced by TGStat::Plot(), and TMAGFitBern::PlotProperties().

123  {
124  SaveEps(PlotFNm.GetFPath()+PlotFNm.GetFMid()+".eps", FontSz, Comment); }
TStr GetFMid() const
Definition: dt.cpp:1403
TStr GetFPath() const
Definition: dt.cpp:1389
void SaveEps(const int &FontSz=30, const TStr &Comment=TStr())
Definition: gnuplot.h:123
TStr PlotFNm
Definition: gnuplot.h:50

Here is the call graph for this function:

Here is the caller graph for this function:

void TGnuPlot::SaveEps ( const TStr FNm,
const int &  FontSz = 30,
const TStr Comment = TStr() 
)

Definition at line 599 of file gnuplot.cpp.

References AddCmd(), CreatePlotFile(), TStr::CStr(), TVec< TVal, TSizeTy >::DelLast(), TStr::Empty(), TStr::Fmt(), MoreCmds, Pause(), RunGnuPlot(), and Title.

599  {
600  AddCmd(TStr::Fmt("set terminal postscript enhanced eps %d color", FontSz));
601  AddCmd(TStr::Fmt("set output '%s'", FNm.CStr()));
602  Pause(false);
603  CreatePlotFile(Comment.Empty()? Title : Comment);
604  RunGnuPlot();
605  MoreCmds.DelLast();
606  MoreCmds.DelLast();
607 }
TStr Title
Definition: gnuplot.h:51
void AddCmd(const TStr &Cmd)
Definition: gnuplot.h:81
void Pause(const bool &DoPause)
Definition: gnuplot.h:77
bool Empty() const
Definition: dt.h:488
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476
void RunGnuPlot() const
Definition: gnuplot.cpp:868
void DelLast()
Removes the last element of the vector.
Definition: ds.h:609
void CreatePlotFile(const TStr &Comment=TStr())
Definition: gnuplot.cpp:763
TStrV MoreCmds
Definition: gnuplot.h:56

Here is the call graph for this function:

void TGnuPlot::SavePng ( const TStr FNm,
const int &  SizeX = 1000,
const int &  SizeY = 800,
const TStr Comment = TStr(),
const TStr Terminal = TStr() 
)

Definition at line 578 of file gnuplot.cpp.

References AddCmd(), CreatePlotFile(), TStr::CStr(), TVec< TVal, TSizeTy >::DelLast(), TStr::Empty(), TStr::Fmt(), MoreCmds, Pause(), RunGnuPlot(), and Title.

578  {
579  if (Terminal.Empty()) {
580  //#ifdef GLib_WIN
581  //#ifndef GLib_MACOSX // The standard GNUPlot for MacOS does not support PNG (Jure: actually version 4.6 DOES!)
582  AddCmd(TStr::Fmt("set terminal png size %d,%d", SizeX, SizeY));
583  AddCmd(TStr::Fmt("set output '%s'", FNm.CStr()));
584  //#else // EPS
585  //AddCmd("set terminal postscript eps 10 enhanced color");
586  //AddCmd(TStr::Fmt("set output '%s%s.eps'", FNm.GetFPath().CStr(), FNm.GetFMid().CStr()));
587  //#endif
588  } else {
589  AddCmd(Terminal);
590  AddCmd(TStr::Fmt("set output '%s'", FNm.CStr()));
591  }
592  Pause(false);
593  CreatePlotFile(Comment.Empty()? Title : Comment);
594  RunGnuPlot();
595  MoreCmds.DelLast();
596  MoreCmds.DelLast();
597 }
TStr Title
Definition: gnuplot.h:51
void AddCmd(const TStr &Cmd)
Definition: gnuplot.h:81
void Pause(const bool &DoPause)
Definition: gnuplot.h:77
bool Empty() const
Definition: dt.h:488
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476
void RunGnuPlot() const
Definition: gnuplot.cpp:868
void DelLast()
Removes the last element of the vector.
Definition: ds.h:609
void CreatePlotFile(const TStr &Comment=TStr())
Definition: gnuplot.cpp:763
TStrV MoreCmds
Definition: gnuplot.h:56

Here is the call graph for this function:

void TGnuPlot::SaveTs ( const TIntKdV KdV,
const TStr FNm,
const TStr HeadLn = TStr() 
)
static

Definition at line 712 of file gnuplot.cpp.

References TStr::CStr(), EAssert, TStr::Empty(), and TVec< TVal, TSizeTy >::Len().

Referenced by TTimeNet::PlotCCfOverTm().

712  {
713  FILE *F = fopen(FNm.CStr(), "wt");
714  EAssert(F);
715  if (! HeadLn.Empty()) fprintf(F, "# %s\n", HeadLn.CStr());
716  for (int i = 0; i < KdV.Len(); i++) {
717  fprintf(F, "%d\t%d\n", KdV[i].Key(), KdV[i].Dat()); }
718  fclose(F);
719 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
#define EAssert(Cond)
Definition: bd.h:280
bool Empty() const
Definition: dt.h:488
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

Here is the caller graph for this function:

void TGnuPlot::SaveTs ( const TIntFltKdV KdV,
const TStr FNm,
const TStr HeadLn = TStr() 
)
static

Definition at line 722 of file gnuplot.cpp.

References TStr::CStr(), EAssert, TStr::Empty(), and TVec< TVal, TSizeTy >::Len().

722  {
723  FILE *F = fopen(FNm.CStr(), "wt");
724  EAssert(F);
725  if (! HeadLn.Empty()) fprintf(F, "# %s\n", HeadLn.CStr());
726  for (int i = 0; i < KdV.Len(); i++)
727  fprintf(F, "%d\t%g\n", KdV[i].Key(), KdV[i].Dat());
728  fclose(F);
729 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
#define EAssert(Cond)
Definition: bd.h:280
bool Empty() const
Definition: dt.h:488
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

template<class TVal1 , class TVal2 >
void TGnuPlot::SaveTs ( const TVec< TPair< TVal1, TVal2 > > &  ValV,
const TStr FNm,
const TStr HeadLn = TStr() 
)
static

Definition at line 215 of file gnuplot.h.

References TStr::CStr(), EAssert, and TStr::Empty().

215  {
216  FILE *F = fopen(FNm.CStr(), "wt");
217  EAssert(F);
218  if (! HeadLn.Empty()) { fprintf(F, "# %s\n", HeadLn.CStr()); }
219  for (int i = 0; i < ValV.Len(); i++) {
220  fprintf(F, "%g\t%g\n", double(ValV[i].Val1), double(ValV[i].Val2)); }
221  fclose(F);
222 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
#define EAssert(Cond)
Definition: bd.h:280
bool Empty() const
Definition: dt.h:488
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

template<class TVal1 , class TVal2 , class TVal3 >
void TGnuPlot::SaveTs ( const TVec< TTriple< TVal1, TVal2, TVal3 > > &  ValV,
const TStr FNm,
const TStr HeadLn = TStr() 
)
static

Definition at line 225 of file gnuplot.h.

References TStr::CStr(), EAssert, and TStr::Empty().

225  {
226  FILE *F = fopen(FNm.CStr(), "wt");
227  EAssert(F);
228  if (! HeadLn.Empty()) { fprintf(F, "# %s\n", HeadLn.CStr()); }
229  for (int i = 0; i < ValV.Len(); i++) {
230  fprintf(F, "%g\t%g\t%g\n", double(ValV[i].Val1), double(ValV[i].Val2), double(ValV[i].Val3)); }
231  fclose(F);
232 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
#define EAssert(Cond)
Definition: bd.h:280
bool Empty() const
Definition: dt.h:488
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

template<class TVal , int Vals>
void TGnuPlot::SaveTs ( const TVec< TTuple< TVal, Vals > > &  ValV,
const TStr FNm,
const TStr HeadLn = TStr() 
)
static

Definition at line 235 of file gnuplot.h.

References TStr::CStr(), EAssert, and TStr::Empty().

235  {
236  FILE *F = fopen(FNm.CStr(), "wt");
237  EAssert(F);
238  if (! HeadLn.Empty()) { fprintf(F, "# %s\n", HeadLn.CStr()); }
239  for (int i = 0; i < ValV.Len(); i++) {
240  fprintf(F, "%g", double(ValV[i][0]));
241  for (int v = 1; v < Vals; v++) {
242  fprintf(F, "\t%g", double(ValV[i][v])); }
243  fprintf(F, "\n");
244  }
245  fclose(F);
246 }
TSizeTy Len() const
Returns the number of elements in the vector.
Definition: ds.h:535
#define EAssert(Cond)
Definition: bd.h:280
bool Empty() const
Definition: dt.h:488
char * CStr()
Definition: dt.h:476

Here is the call graph for this function:

void TGnuPlot::SetDataPlotFNm ( const TStr DatFNm,
const TStr PltFNm 
)
inline

Definition at line 74 of file gnuplot.h.

References DataFNm, and PlotFNm.

Referenced by TAGMFit::RunMCMC().

74 { DataFNm = DatFNm; PlotFNm = PltFNm; }
TStr DataFNm
Definition: gnuplot.h:50
TStr PlotFNm
Definition: gnuplot.h:50

Here is the caller graph for this function:

void TGnuPlot::SetLineStyle ( const int &  PlotId,
const TStr StyleStr 
)
inline

Definition at line 83 of file gnuplot.h.

References SeriesV.

83 { SeriesV[PlotId].WithStyle = StyleStr; }
TVec< TGpSeries > SeriesV
Definition: gnuplot.h:55
void TGnuPlot::SetTitle ( const TStr PlotTitle)
inline

Definition at line 70 of file gnuplot.h.

References Title.

Referenced by TAGMFit::RunMCMC().

70 { Title = PlotTitle; }
TStr Title
Definition: gnuplot.h:51

Here is the caller graph for this function:

void TGnuPlot::SetXLabel ( const TStr XLabel)
inline

Definition at line 71 of file gnuplot.h.

References LblX.

71 { LblX = XLabel; }
TStr LblX
Definition: gnuplot.h:51
void TGnuPlot::SetXRange ( const double &  Min,
const double &  Max 
)
inline

Definition at line 79 of file gnuplot.h.

References XRange.

Referenced by TLocClustStat::ImposeNCP(), TLocClustStat::PlotNCP(), TLocClustStat::PlotNCPModul(), TLocClustStat::PlotNCPScatter(), TLocClustStat::PlotNcpTop10(), and TLocClustStat::PlotPhiInOut().

79 { XRange = TFltPr(Min, Max); }
TFltPr XRange
Definition: gnuplot.h:53
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99

Here is the caller graph for this function:

void TGnuPlot::SetYLabel ( const TStr YLabel)
inline

Definition at line 72 of file gnuplot.h.

References LblY.

72 { LblY = YLabel; }
TStr LblY
Definition: gnuplot.h:51
void TGnuPlot::SetYRange ( const double &  Min,
const double &  Max 
)
inline

Definition at line 80 of file gnuplot.h.

References YRange.

Referenced by PlotGrad().

80 { YRange = TFltPr(Min, Max); }
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
TFltPr YRange
Definition: gnuplot.h:53

Here is the caller graph for this function:

void TGnuPlot::ShowGrid ( const bool &  Show)
inline

Definition at line 76 of file gnuplot.h.

References SetGrid.

Referenced by TMAGFitBern::PlotProperties().

76 { SetGrid = Show; }
bool SetGrid
Definition: gnuplot.h:54

Here is the caller graph for this function:

void TGnuPlot::Test ( )
static

Definition at line 731 of file gnuplot.cpp.

References TVec< TVal, TSizeTy >::Add(), AddErrBar(), AddLinFit(), AddPlot(), gpwLines, gpwPoints, Plot(), TInt::Rnd, SavePng(), and SetXYLabel().

731  {
732  TFltV DeltaY;
733  TFltPrV ValV1, ValV2, ValV3;
734  for (int i = 1; i < 30; i++) {
735  ValV1.Add(TFltPr(i, pow(double(i), 1.2)));
736  DeltaY.Add(5*TInt::Rnd.GetUniDev());
737  ValV2.Add(TFltPr(i, 5*i-1));
738  }
739  for (int i = -10; i < 20; i++) {
740  ValV3.Add(TFltPr(i, 2*i + 2 + TInt::Rnd.GetUniDev()));
741  }
742  TGnuPlot GnuPlot("testDat", "TestPlot", true);
743  GnuPlot.SetXYLabel("X", "Y");
744  const int id2 = GnuPlot.AddPlot(ValV2, gpwPoints, "y=5*x-1");
745  const int id3 = GnuPlot.AddPlot(ValV3, gpwPoints, "y=2*x+2");
746  GnuPlot.AddErrBar(ValV1, DeltaY, "y=x^2", "Error bar");
747  GnuPlot.AddLinFit(id2, gpwLines);
748  GnuPlot.AddLinFit(id3, gpwLines);
749  GnuPlot.Plot();
750  GnuPlot.SavePng("testPlot.png");
751 }
static TRnd Rnd
Definition: dt.h:1050
TPair< TFlt, TFlt > TFltPr
Definition: ds.h:99
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
Vector is a sequence TVal objects representing an array that can change in size.
Definition: ds.h:420

Here is the call graph for this function:

Member Data Documentation

TStr TGnuPlot::DataFNm
private
TStr TGnuPlot::DefDataFNm = "GnuPlot.tab"
static

Definition at line 23 of file gnuplot.h.

TStr TGnuPlot::DefPlotFNm = "GnuPlot.plt"
static

Definition at line 22 of file gnuplot.h.

TStr TGnuPlot::GnuPlotFNm = "gnuplot"
static

GnuPlot executable file name. Set if different than the standard wgnuplot/gnuplot.

Definition at line 21 of file gnuplot.h.

Referenced by RunGnuPlot().

TStr TGnuPlot::GnuPlotPath = "/usr/bin"
static

Path to GnuPlot executable. Set if gnuplot is not found in the PATH.

Definition at line 19 of file gnuplot.h.

Referenced by RunGnuPlot().

TStr TGnuPlot::LblX
private

Definition at line 51 of file gnuplot.h.

Referenced by CreatePlotFile(), operator=(), SetXLabel(), and SetXYLabel().

TStr TGnuPlot::LblY
private

Definition at line 51 of file gnuplot.h.

Referenced by CreatePlotFile(), operator=(), SetXYLabel(), and SetYLabel().

TStrV TGnuPlot::MoreCmds
private

Definition at line 56 of file gnuplot.h.

Referenced by AddCmd(), CreatePlotFile(), operator=(), SaveEps(), and SavePng().

TStr TGnuPlot::PlotFNm
private

Definition at line 50 of file gnuplot.h.

Referenced by CreatePlotFile(), operator=(), RunGnuPlot(), SaveEps(), SavePng(), and SetDataPlotFNm().

TGpScaleTy TGnuPlot::ScaleTy
private

Definition at line 52 of file gnuplot.h.

Referenced by CreatePlotFile(), operator=(), and SetScale().

bool TGnuPlot::SetGrid
private

Definition at line 54 of file gnuplot.h.

Referenced by CreatePlotFile(), operator=(), and ShowGrid().

bool TGnuPlot::SetPause
private

Definition at line 54 of file gnuplot.h.

Referenced by CreatePlotFile(), operator=(), and Pause().

int TGnuPlot::Tics42 = -2
staticprivate

Definition at line 48 of file gnuplot.h.

Referenced by CreatePlotFile().

TStr TGnuPlot::Title
private

Definition at line 51 of file gnuplot.h.

Referenced by AddErrBar(), AddPlot(), CreatePlotFile(), operator=(), SaveEps(), SavePng(), and SetTitle().

TFltPr TGnuPlot::XRange
private

Definition at line 53 of file gnuplot.h.

Referenced by CreatePlotFile(), operator=(), and SetXRange().

TFltPr TGnuPlot::YRange
private

Definition at line 53 of file gnuplot.h.

Referenced by CreatePlotFile(), operator=(), and SetYRange().


The documentation for this class was generated from the following files: