39

My question is very similar in spirit to this question: What is the best plotting library for Python?

What is my best bet for plotting data in C? Am I better off forgoing a library and just generating data that I can feed directly into gnuplot?

My impetus for this question is being able to visualize DSP transformations while studying the excellent resources found in an earlier question of mine. So the focus is really just 2D plots, histograms, etc.; 3D isn't as important right now.

Community
  • 1
  • 1
Kevin L.
  • 4,548
  • 7
  • 39
  • 54

6 Answers6

21

I think you are on the right track with gnuplot. For what you want, it's very powerful and flexible.

However, you may want to consider writing to gnuplot directly from your application instead of creating data and feeding it. There is an ANSI C API to gnuplot available.

Reed Copsey
  • 554,122
  • 78
  • 1,158
  • 1,373
  • I've developed gnupplus, a c++ variant of the library you linked. You can find a link for it on the same webpage you posted. – Dacav Jun 30 '10 at 20:24
  • You can either fork/exec gnuplot and feed it through a pipe, or simply output your data on the standard output and pipe it to gnuplot. I usually like the 2nd solution better since it allows you to use `awk` (or anything else) to modify the gnuplot script beforehand. – Alexandre C. Jun 08 '11 at 07:31
7

MathGL is cross-platform (Windows/Linux/MacOS) free (GPL, LGPL for core) plotting library. It is fast, have a lot of graphics types, can plot huge data arrays, can produce bitmap and vector (EPS/SVG/U3D) output, can use OpenGL, can run in console (don't need X), have many interfaces (Fortran/Python/... to combine with other languages), have FLTK/Qt widgets, can create its own window with plotting, and so on.

abalakin
  • 825
  • 7
  • 6
  • It seems quite heavy, but for "production" type code, it seems great. For prototyping though, gnuplot is unbeatable. – Alexandre C. Jun 08 '11 at 07:34
  • I just experienced dependency he!l trying to do static linking with MathGL on MINGW. Just my experiences so far. –  Jan 17 '13 at 22:01
3

libgd. But if you don't have a lot of data to plot, gnuplot is a good way to go, as others suggested.

cat
  • 3,888
  • 5
  • 32
  • 61
xcramps
  • 1,203
  • 1
  • 9
  • 9
2

I've found PLplot which seems to be interesting. I'm trying it right now and I'll publish here a quick review about it as I'll know something more about it.

Update: As first blush it seems to be badly designed, since it adds interactivity to the application (IMHO a library should never directly interface with the user unless this is the library's purpose).

Community
  • 1
  • 1
Dacav
  • 13,590
  • 11
  • 60
  • 87
1

On Mac OS X you may also feed your data directly into Plot which features Perl-based scripting and a command-line interface for non-interactive data processing:

http://plot.micw.eu

In terms of a Mac OS X C-ish plotting framework see core-plot.

Community
  • 1
  • 1
-1

have you looked at AntiGrain? it's multiplatform