I have an application which logs periodically on to a host system it could be on a file or just a console. I would like to use this data to plot a statistical graph for me. I am not sure if I can use the live graph for my application.
If this tool is the right one, may I have an example on integrating the external application with the live graph?
this is livegraph link --> http://www.live-graph.org/download.html
Well, you only need to write your data in the given format of livegraph and set livegraph up to plot what you want. If wrote small C example which generates random numbers and dumps them together with the time every second. Next, you just attach the livegraph program to the file. That's it.
Playing around with LiveGraph I must say that its use is rather limited. I still would stick to a python script with matplotlib, since you have much more control over how and what is plotted.
compile with
I think this can be achieved easiest using Python plus matplotlib. To achieve this there are actually multiple ways: a) integrating the Python Interpreter directly in your C application, b) printing the data to stdout and piping this to a simple python script that does the actual plotting. In the following I will describe both approaches.
We have the following C application (e.g.
plot.c
). It uses the Python interpreter to interface with matplotlib's plotting functionality. The application is able to plot the data directly (when called like./plot --plot-data
) and to print the data tostdout
(when called with any other argument set).You can build it like this:
And run it like:
Then it will run for some time plotting red dots onto an axis.
When you choose not to plot the data directly but to print it to the
stdout
you may do the plotting by an external program (e.g. a Python script namedplot.py
) that takes input fromstdin
, i.e. a pipe, and plots the data it gets. To achieve this call the program like./plot | python plot.py
, withplot.py
being similar to:I have tested both approaches on my debian machine. It requires the packages
python2.7
andpython-matplotlib
to be installed.EDIT
I have just seen, that you wanted to plot a bar plot or such thing, this of course is also possible using matplotlib, e.g. a histogram: