PDA

View Full Version : plotting package for data




vgoklani
Mar 29, 2007, 07:47 PM
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.



ChrisA
Mar 29, 2007, 08:46 PM
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.

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.

Nuc
Mar 29, 2007, 08:47 PM
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.

vgoklani
Mar 29, 2007, 09:14 PM
"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!

irbdavid
Apr 2, 2007, 12:43 PM
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).

vgoklani
Apr 4, 2007, 12:10 PM
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-

ChrisA
Apr 4, 2007, 01:50 PM
"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!
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.

vgoklani
Apr 4, 2007, 07:55 PM
#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";
}

MrFusion
Apr 8, 2007, 05:39 PM
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.

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.