ckplot

Unnamed repository
Log | Files | Refs

commit c0fc4a9e521caacfcd2355e251818b1fc22f9b3d
parent c4247c328dbba95c3c33c6304cbfbe82f4c8617d
Author: phoebos <ben@bvnf.space>
Date:   Sun,  3 Oct 2021 02:30:43 +0100

kplot: if only one column, print it against index

Diffstat:
Mkplot.c | 11++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/kplot.c b/kplot.c @@ -101,7 +101,7 @@ main(int argc, char **argv) { perror("csv_read_file"); return 1; } - if (c->cols != 2) { + if (c->cols > 2) { fprintf(stderr, "warning: %d columns in file but only using first two\n", c->cols); } if (c->rows < 1) { @@ -114,8 +114,13 @@ main(int argc, char **argv) { struct kpair points1[c->rows]; for (int i = 0; i < c->rows; i++) { - points1[i].x = c->data[i][0]; - points1[i].y = c->data[i][1]; + if (c->cols == 1) { + points1[i].x = i; + points1[i].y = c->data[i][0]; + } else { + points1[i].x = c->data[i][0]; + points1[i].y = c->data[i][1]; + } } char *xlabel, *ylabel;