Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

vgoklani

macrumors regular
Original poster
Jul 2, 2004
186
0
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

macrumors G5
Jan 5, 2006
12,907
2,155
Redondo Beach, California
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

macrumors 6502a
Jan 20, 2003
798
6
TN
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

macrumors regular
Original poster
Jul 2, 2004
186
0
"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

macrumors regular
Mar 27, 2006
154
0
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

macrumors regular
Original poster
Jul 2, 2004
186
0
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

macrumors G5
Jan 5, 2006
12,907
2,155
Redondo Beach, California
"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

macrumors regular
Original poster
Jul 2, 2004
186
0
#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

macrumors 6502a
Jun 8, 2005
613
0
West-Europe
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.