plotting package for data

Discussion in 'Mac Programming' started by vgoklani, Mar 29, 2007.

  1. macrumors regular

    vgoklani

    Joined:
    Jul 2, 2004
    #1
    Hi,

    I am looking for a good plotting package for plotting data on a mac. I typically have several pages of code from C++, and I need something to plot x vs y, etc. What would you recommend? Does anyone know a package that makes use of Apple's core APIs? I am too lazy to use GNUplot, I would prefer something more mac-ish.
     
  2. macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #2
    Try "Grapher". It's in the utilities folder.

    I was about to say that you could call gnuplot from inside C++ using system() But you said more mac-like.
     
  3. Nuc
    macrumors 6502a

    Nuc

    Joined:
    Jan 20, 2003
    Location:
    TN
    #3
    I'm sure you can use the Grapher that comes with OSX. I'm not to sure how to link it but I believe there are docs on this on the developer website.

    Nuc

    Edit: beaten to it.
     
  4. thread starter macrumors regular

    vgoklani

    Joined:
    Jul 2, 2004
    #4
    "I was about to say that you could call gnuplot from inside C++ using system() But you said more mac-like."

    How would I do this? This would be really ideal!
     
  5. macrumors regular

    irbdavid

    Joined:
    Mar 27, 2006
    #5
    Depending on the exact problem I'll use one of a few things.

    By far the simplest approach is to just dump the data you want plotted to a file in gnuplot format, write a gnuplot script to actually plot the data, set titles etc and export a postscript or whatever file format you're after of the final plot. If you can code in C++ there's no way this will make you even break a sweat :)
    Gnuplot is also a doddle to install and easy to learn the syntax for.

    As far as plotting the data from within C++ goes, things get much more complicated. For various reasons, I'm still using a program called PGPlot for this, which is kinda limited - can't do any 3d stuff for example. It's old, but it was relatively simple to compile and get running a mac. Docs for it are also teh suck, so.... probably you don't want this.

    PLPlot is newer, more up to date and more capable, but this gave me lip when I tried installing it and using last time, and I didn't really persevere much with it.

    For all 3 of these options, you can get the "Mac-like" part by using Aquaterm as the display device, essentially avoiding having to use X11, which solves a few problems and makes some of the useful mac things available (Print to PDF etc).
     
  6. thread starter macrumors regular

    vgoklani

    Joined:
    Jul 2, 2004
    #6
    Could you post your scripts online (and the calls from your sourcecode to PGPlot), I would like to take a look at them. Sometimes, seeing a simple example can elucidate things tremendously.

    Thanks!

    -V-
     
  7. macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #7
    or
    Have you looked at the "system()" man page? Read it then post questions here but I doubt you would need to. It's easy.

    system is a standard C library function. It will execute the command given as an argument and block until the command completes.

    The blocking part is a bit primitive so many people would prefer to use a fork() followed by exec() Being unblocked means you can continue to run your user interface.
     
  8. thread starter macrumors regular

    vgoklani

    Joined:
    Jul 2, 2004
    #8
    #include <iostream>

    int main()
    {
    if (std::system(0)) // A command processor is available.
    std::system("ls");
    else
    std::cerr << "A command processor is not available.\n";
    }
     
  9. macrumors 6502a

    Joined:
    Jun 8, 2005
    Location:
    West-Europe
    #9
    You're in luck (or not, that depends what you think of my programming abilities). Being fed up with having to type everything on the commandline for gnuplot, I am working on "interface program". By specifying a few things such as title, xlabel, ylable, files to plot. it generates a temporary gnuplot file copies the data files to a temp dir, strips out bad bytes (^M) and plot it to an aqua term. That plot in aqua term then can be saved as pdf and preview can convert that to png, or whatever you like.

    I wrote in less than two weekends (just this easter and previous weekend), and it's the first programme since I started using cocoa (1+year) that actually could be used. Thank you all for replying to my questions!

    The programme uses coredata and bindings, and I went for a short programming time, not a fancy program.

    If you or anyone else is interested in it, or just want to test it for me or give feedback (no trolling please), drop me a line.

    I am hoping that Leopard will include some API's for plotting data.

    To be clear: this is "use at your own peril" software.
     

Share This Page