0

I know there are already other posts about this, but I am unable to get the recommended libraries running.

I am writing a program in C. I am fairly inexperienced at programming. I need to plot the results on an x-y graph. There will be potentially hundreds or even thousands of points. The points will be plotted as the program calculates them, so the graph may need to scroll sideways if the x-axis is exceeded.

So, basically, what I need to do is open a window with x-y axes and plot points in this graph as my program comes up with the numbers. I am looking for the simplest and quickest way to get this written, and it's just a way for me to visualise the results. Can C handle this or do I need a library? If a library, I need one that is easy to set up as my experience is limited.

Thanks in advance Andrew

3
  • 4
    What platform are you working on? Jul 14, 2011 at 14:18
  • have you considered using MATLAB, this would be really simple to do in that... however a full implementation in MATLAB of your program depends on what the rest of your program does
    – rrazd
    Jul 14, 2011 at 16:51
  • or, instead of MATLAB, try GNU Octave. I usually use R or Octave for my "graphs", but years ago I used gnuplot and was satisfied (but C outputs just numbers, not used to plot for real); when I "needed" to do it really from from C, I tried plotutils gnu.org/s/plotutils and was satisfied Jul 14, 2011 at 19:42

2 Answers 2

1

If you look for a library to be linked into yours program then MathGL (cross-platform GPL plotting library) is better than gnuplot. At this, it can handle huge data sets, can collect plotting (i.e. add plot, add new plot, add new plot, ..., save current result/plot, add new plot, ..., save result). And MathGL have C interface too.

I'm a bit confused by words "so the graph may need to scroll sideways if the x-axis is exceeded". Because it is difficult to place a point (plot) if one don't know the final axis scale(s).

May be you need just a bitmap (or XPM image - 2D array of char) each row/column is proportional to time-step and the height of point is proportional to data value, like h[i] = Height*(y[i]-ymin)/(ymax-ymin).

0

I would use gnuplot if on *nix
http://ndevilla.free.fr/gnuplot/
http://ndevilla.free.fr/gnuplot/gnuplot_i/index.html

Looks pretty easy to me

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.