From 125ad02159a4048e4bbb8d18a31a95e2975d3ef1 Mon Sep 17 00:00:00 2001 From: Andrew Zhen Ning Yong Date: Wed, 20 Feb 2019 16:35:14 +0000 Subject: [PATCH] latan-plot now takes extra option: spacing between data points, adjustable plot range --- utils/plot.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/utils/plot.cpp b/utils/plot.cpp index 878095a..d5c624b 100644 --- a/utils/plot.cpp +++ b/utils/plot.cpp @@ -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,16 +43,16 @@ int main(int argc, char *argv[]) } plotFileName = opt.getArgs()[0]; xName = opt.optionValue("x"); + xLow = opt.optionValue("l"); yName = opt.optionValue("y"); + spacing = opt.optionValue("s"); title = opt.optionValue("t"); - // corrFileName = opt.getArgs()[1]; - // corr0FileName = opt.getArgs()[2]; outFileName = opt.optionValue("o"); // load file ///////////////////////////////////////////////////////// DMatSample tmp; Index nt; - + tmp = Io::load(plotFileName); nt = tmp[central].rows(); tmp = tmp.block(0, 0, nt, 1); @@ -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();