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

latan-plot now takes extra option: spacing between data points, adjustable plot range

This commit is contained in:
Andrew Zhen Ning Yong 2019-02-20 16:35:14 +00:00
parent 36fb53b0f6
commit 125ad02159

View File

@ -17,13 +17,18 @@ int main(int argc, char *argv[])
OptParser opt;
bool parsed;
string plotFileName, outFileName, xName, yName, title;
double xLow, xHigh, spacing;
opt.addOption("o", "output", OptParser::OptType::value , true,
"output file", "");
opt.addOption("x", "xAxis", OptParser::OptType::value , true,
"x-axis name", "");
opt.addOption("l", "xLow", OptParser::OptType::value , true,
"x-axis lower bound", "0");
opt.addOption("y", "yAxis", OptParser::OptType::value , true,
"y-axis name", "");
opt.addOption("s", "spacing", OptParser::OptType::value , true,
"spacing between points", "1");
opt.addOption("t", "title", OptParser::OptType::value , true,
"plot title", "");
opt.addOption("", "help" , OptParser::OptType::trigger, true,
@ -38,10 +43,10 @@ int main(int argc, char *argv[])
}
plotFileName = opt.getArgs()[0];
xName = opt.optionValue("x");
xLow = opt.optionValue<double>("l");
yName = opt.optionValue("y");
spacing = opt.optionValue<double>("s");
title = opt.optionValue("t");
// corrFileName = opt.getArgs()[1];
// corr0FileName = opt.getArgs()[2];
outFileName = opt.optionValue<string>("o");
// load file /////////////////////////////////////////////////////////
@ -57,11 +62,11 @@ int main(int argc, char *argv[])
Plot p;
DVec tAxis;
tAxis.setLinSpaced(nt, 0, nt-1);
xHigh= xLow+spacing*(nt-1);
tAxis.setLinSpaced(nt, xLow, xHigh);
p << Label(xName, Axis::x);
p << Label(yName, Axis::y);
p << PlotRange(Axis::x, 0, nt);
p << PlotRange(Axis::y, -0.1, 0.1);
p << PlotRange(Axis::x, xLow, xHigh);
p << Color("rgb 'red'") << PlotData(tAxis, tmp);
p << Caption(title);
p.display();