1. 6

Hey Lobsters, I wrote this little tool such that I can generate graphs easily on the command line. It’s nothing much now, but it’s saved me a bunch of time already, so I’d love your feedback!


  2. 4

    Something that I’ve wanted recently was a way to generate histograms based on event logs, not periodic logs (which are typically gauges and make more sense with linegraphs). I wrote a script to do it with gnuplot, and it took me a few hours but wasn’t too painful. It seems like it might be worthwhile just to write a wrapper around gnuplot that graphs different kinds of logged data nicely.

    Edit: I previously wrote “ggplot2” instead of “gnuplot”, but my post didn’t make much sense.

    1. 4

      ggplot2 requires R, right? I don’t have R on my machine, and while I’m sure it’s a fantastic language, it’s probably completely overkill for the types of situations I have in mind for grapt. If I’m looking to prepare graphs for slides or “publication” I’d certainly use a different tool.

      That said, there’s no real reason that grapt couldn’t serve the purposes of “prepping graphs for slides or publication” it’s just not something that I do very often at all, and isn’t really in my purview.

      1. 3

        Whoops, I meant gnuplot, not ggplot2. Sorry! I’ve edited my comment to reflect that.

    2. 3

      Similar frustration lead to this: https://github.com/zevweiss/plot (matplotlib-based; somewhat more featureful at time of writing; should probably have a less-broad name).

      This seems like something that there should be some well-established existing tools for, but I’ve yet to come across any (maybe I just haven’t been looking in the right places).

      1. 1

        This seems like something that there should be some well-established existing tools for, but I’ve yet to come across any (maybe I just haven’t been looking in the right places).

        I agree! There’s lots of graphing tools, but none designed for DWIM use. They’re mostly interactive, or designed to be used as a library (like ggplot2 and friends), etc. They also come with a lot of required dependencies! Grapt, will hopefully have very few dependencies a C compiler and a graphics lib (currently just cairo, which is a pretty big dependency, I’ll admit).

      2. 3


        The GNU plotutils package contains software for both programmers and technical users. Its centerpiece is libplot, a powerful C/C++ function library for exporting 2-D vector graphics in many file formats, both vector and bitmap. On the X Window System, it can also do 2-D vector graphics animations.

        libplot is device-independent, in the sense that its API (application programming interface) does not depend on the type of graphics file to be exported. A Postscript-like API is used both for file export and for graphics animations. A libplot programmer needs to learn only one API: not the details of many graphics file formats.

        The package also contains command-line programs for plotting scientific data, such as GNU graph for XY plotting. Many of them use libplot to export graphics. So, they can export graphics in any of libplot’s supported formats, such as

        SVG (Scalable Vector Graphics format), the XML-based format for Web graphics, which is standardized by the W3 Consortium.
        PNG, the open format for bitmap graphics. (Whenever a bitmap output format is being generated, libplot converts Postscript-style paths to bitmaps.)
        The format used by the free xfig drawing editor. (Edit a 2-D drawing with a mouse, after generating it programmatically!)
        Postscript itself.

        The current version of the plotutils package is 2.6, released September 2009. It can be installed on GNU/Linux, FreeBSD, and Unix systems.

        The plotutils package comes with a 185-page manual. Here is an English-language version of the manual, and here is a Japanese-language version of the manual. People working through the many examples given in the manual should look at the expected output expected output (PDF). (Thanks to Daisuke TOMINAGA for the last two items!).

        The package is free software. Its source code is distributed as a 3.7 megabyte gzipped tar file. Here is how you can get it. What command-line programs does the package contain?

        It includes

        GNU graph, which plots 2-D datasets or data streams in real time. Being designed for command-line use, it can be used in shell scripts. It produces output on an X Window System display, in SVG format, in PNG format, in PNM format, in pseudo-GIF format, in WebCGM format, in Illustrator format, in Postscript format, in PCL 5 format, in HP-GL/2 format, in Fig format (editable with the xfig drawing editor), in ReGIS format, in Tektronix format, or in GNU Metafile format. Output in Postscript format may be edited with the idraw drawing editor. idraw is available in the ivtools package from Vectaport, Inc. Both xfig and idraw are free software.
        GNU plot, which translates GNU Metafile format to any of the other formats.
        GNU tek2plot, for translating legacy Tektronix data to any of the above formats.
        GNU pic2plot, for translating the pic language (a scripting language for designing box-and-arrow diagrams) to any of the above formats. The pic language was designed at Bell Labs as an enhancement to the troff text formatter.
        GNU plotfont, for displaying character maps of the fonts that are available in the above formats.
        GNU spline, which does spline interpolation of data. It normally uses either cubic spline interpolation or exponential splines in tension, but it can function as a real-time filter under some circumstances.
        GNU ode, which numerically integrates a system consisting of one or more ordinary differential equations.

        We developed these command-line programs to replace the Unix command-line programs graph, plot, and spline. The GNU versions are far more powerful, and are free software.

        1. 1

          fwiw, you can do this exact thing with spark: - https://github.com/holman/spark

          11:45 AM noon@>iostat 1 5 | grep 'sda' | awk '{print $2}' | spark
          1. 2

            I wouldn’t exactly call it the exact thing, but yes, it has similar goals. Thanks for linking!

            1. 2

              by “exact” i mean “generate graphs entirely in the command line”, which is how i interpreted your goal - yours doesn’t do this “exact thing” in this sense.