graphing C++ output

Discussion in 'Mac Programming' started by weilanddavid, Jan 8, 2007.

  1. weilanddavid macrumors newbie

    Oct 22, 2006
    What is the best (basic) approach to graphically representing the output of C++ programs (in Xcode)? Anything from plotting a basic graph (y=f(x)) to constructing an animation of some process that evolves over time. Two-dimensional is sufficient for now. Best place to begin? Many thanks for suggestions, David
    OS X 10.4.8, 1.83 GHz Macbook, XCode 2.4.1
  2. garethlewis2 macrumors 6502

    Dec 6, 2006
    You could create a Cocoa wrapper project. This would comprise a button labelled something like runit, along with an NSView class that would graph your data. The runit button would execute your C++ program in an NSThread or similar and your NSView would receive notification alerts to state that more output is ready to be drawn.

    There are probably simpler alternatives, I'm just putting an idea forward.
  3. AlmostThere macrumors 6502a

    Write the data / function to a text file and use gnuplot (

    If you have never used it before, there is an excellent reference / tutorial at this site

    It is quick, easy and works every time, and it will do 3 dimensions, too.

    Quicktime and a whole host of other apps can build animations from a series of images.

    A little bit of shell scripting can connect all these bits together very quickly.
  4. weilanddavid thread starter macrumors newbie

    Oct 22, 2006
    ummm, you're over my head. :confused: let me try another guess. run the c program and put the data into a file. then write a java program (i've never written anything in java, so i'm just guessing here) to read the file and draw it appropriately. one of my goals is to produce publication quality diagrams, so creating an actual picture file is important as well. so, two questions here. 1. separating the computation and the drawing into two separate programs a good idea? 2. is java the best way for beginner to 'draw'?
  5. weilanddavid thread starter macrumors newbie

    Oct 22, 2006
    wrote my last reply before reading AlmostThere. sounds good, i'll look into it. thanks, david
  6. lazydog macrumors 6502a

    Sep 3, 2005
    Cramlington, UK

    Last time I looked there were a few programs in the Maths and Science section of the Downloads area on the Apple site that will plot graphs from data files.

    b e n
  7. AlmostThere macrumors 6502a

    And if you are using 10.4, then /Applications/Utilities/ might well be of interest for plotting functions

Share This Page