tobbes has asked for the wisdom of the Perl Monks concerning the following question:

I am not able to find anything to suite my needs. The program needs to recieve data in realtime and plot them on a graph. Idealy the graph should also be interactive, you should be able to click on it and set listeners. I have found a very good module in python here but unfortunately the script I am going to extend is written in perl. I have also tried to install Inline::Python without success as I am running windows 10. Does anyone know of a perl library resembling matplotlib?

Replies are listed 'Best First'.
Re: Library for realtime graphs in perl.
by zentara (Archbishop) on Oct 17, 2018 at 12:17 UTC
    Hi, see Tk Realtime data aquisition. It has a simple realtime graph on a Tk::Canvas. You will have to put some of your own work into it, if you want interactivity, but almost anything can be easily added. Read the comments if you are using MSWindows, for how to deal with Window's fileevent problems.

    I'm not really a human, but I play one on earth. ..... an animated JAPH
      Thanks, I will look into it.:)
        You might want to use for the client ip address if testing on a single local machine. The address was just for testing on my local network.
        #my $machine_addr = ''; my $machine_addr = '';

        I'm not really a human, but I play one on earth. ..... an animated JAPH
Re: Library for realtime graphs in perl.
by Discipulus (Canon) on Oct 17, 2018 at 12:07 UTC
    Hello, tobbes,

    fortunately the program you have to extend is in Perl ;=)

    You can try GD::Graph and additionally you can take a look to doughnut charts with gd:graph where marto points to a useful article.

    See also this extract

    For the interactive part.. I suppose you need some web interface to achieve interactivity, or a GUI like a Tk program.


    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
      Thanks. I have looked into GD::Graph, but as I have used it to get output you generate an image from it. Now, I will be needing to regenerate this imagefile at least 10 times per second and I am in doubt as to whether perl can generate images at that rate. Also the user should be able to watch the image as the graph is drawn. There are a number of javascript libraries for this (most notably maybe Google::Charts) but alas the users will have no access to the internet. There are other javascript opitons as well which abandoned for reasons I don't recall at the moment :).

        I don't think ten images per second is unreasonable. Of course, it depends on the amount of CPU you can dedicate to it, the complexity of the images, and how efficiently your code is written, but this article talks about GD generating an image in 0.003110 seconds and some digging in the Wayback Machine indicates that those numbers are from over ten years ago; on a modern CPU it should be faster. (The article was a test of the PHP bindings for LibGD, but it's the same underlying C library, so I don't see any reason why the Perl bindings would be significantly slower.)

Re: Library for realtime graphs in perl.
by VinsWorldcom (Prior) on Oct 17, 2018 at 13:53 UTC
Re: Library for realtime graphs in perl.
by Anonymous Monk on Oct 17, 2018 at 14:16 UTC
    "I'm maintaining a full 60 frames per second"

    My DeLorean runs Perl:
    DeLorean Digital Dashboard, demo mode:

    2015 Michael Conrad DeLorean Digital Dashboard:

    2018 Michael Conrad -
    "Building the Graphics of the DeLorean Digital Dash":
Re: Library for realtime graphs in perl.
by zentara (Archbishop) on Oct 22, 2018 at 12:02 UTC
Re: Library for realtime graphs in perl.
by iguanodon (Priest) on Oct 22, 2018 at 13:51 UTC
    Hi tobbes. You mentioned interactive graphs. You might want to look at JavaScript libraries. I have used dygraphs with Perl, for example a Mojolicious app that passes CSV data to dygraphs. There are Link Interaction and Dynamic update examples that might help you.
Re: Library for realtime graphs in perl.
by cavac (Parson) on Oct 22, 2018 at 14:47 UTC

    While not strictly within your requirements, you could one of the many HTML/Javascript based plotting libraries and feed it pseudo-realtime data via websockets. This demo does it, except without the websockets part.

    Or you could code your own webbased solution with HTML5 Canvas and websockets, for which it is also very easy to feed back user interactrion to your backend. While not a graph, a demo of the technology is here on my blog, and a description about interprocess messaging with Net::Clacks to feed data between the webserver and the backend is here: Interprocess messaging with Net::Clacks

    Of course, this is only the way i would have solve, or rather have solved it in the past. And yes, this post is a shameless plug for my very own Net::Clacks ;-)

    perl -e 'use MIME::Base64; print decode_base64("4pmsIE5ldmVyIGdvbm5hIGdpdmUgeW91IHVwCiAgTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duLi4uIOKZqwo=");'