ckplot

Unnamed repository
Log | Files | Refs

commit c4247c328dbba95c3c33c6304cbfbe82f4c8617d
parent 5bbd587cf75a40576c7a9c221743f3d0abe24e09
Author: aabacchus <ben@bvnf.space>
Date:   Sun,  3 Oct 2021 02:10:32 +0100

kplot: add -O|-X to choose data marker format

Diffstat:
Mkplot.c | 17+++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/kplot.c b/kplot.c @@ -11,29 +11,32 @@ void usage(char *argv0) { - fprintf(stderr, "usage: %s [-HTwoh] [file.csv]\n", argv0); + fprintf(stderr, "usage: %s [-HTwoh] [-O|-X] [file.csv]\n", argv0); fprintf(stderr, " -H treat first line as header\n"); fprintf(stderr, " -T format output format (options \"png\", \"pdf\")" " (default: \"pdf\")\n"); fprintf(stderr, " -o outfile output filename\n"); fprintf(stderr, " -w width\n"); fprintf(stderr, " -h height\n"); + fprintf(stderr, " -O data markers are circles\n"); + fprintf(stderr, " -X data markers are crosses\n"); } int main(int argc, char **argv) { - int ch, flag_H, flag_o, output_type, width, height, w, h; + int ch, flag_H, flag_o, output_type, width, height, w, h, point_type; char *outfile; flag_H = flag_o = 0; width = 600; height = 400; + point_type = KPLOT_POINTS; enum { OUT_PNG, OUT_PDF }; output_type = OUT_PDF; outfile = "out.pdf"; - while ((ch = getopt(argc, argv, "HT:o:w:h:")) != -1) { + while ((ch = getopt(argc, argv, "HT:o:w:h:OX")) != -1) { switch (ch) { case 'H': flag_H = 1; @@ -69,6 +72,12 @@ main(int argc, char **argv) { } width = w; break; + case 'O': + point_type = KPLOT_POINTS; + break; + case 'X': + point_type = KPLOT_MARKS; + break; case '?': usage(*argv); return 1; @@ -134,7 +143,7 @@ main(int argc, char **argv) { d1 = kdata_array_alloc(points1, rows); p = kplot_alloc(&kpcfg); - kplot_attach_data(p, d1, KPLOT_POINTS, NULL); + kplot_attach_data(p, d1, point_type, NULL); kdata_destroy(d1); if (output_type == OUT_PNG) surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);