Plotting a graph/function in C++

Discussion in 'Software' started by adamlange, Mar 5, 2005.

  1. adamlange

    adamlange Private E-2

    Hi. How would I plot a graph in c++? I don't want anything fancy. I just want to take a graph and plot some dots like this....


    Code:
    for(int i = 0; i <10; i++)
    {
    
    plotTheDot( i , i^2 );
    
    }
    
    so basically it will just plot some dots for the graph of y=x^2 at i^2, (i+1)^2, (i+2)^2, etc, etc....

    How would i do that? thanks! :)
     
  2. rmStar-R

    rmStar-R Private E-2

    Why don't you do the following?

    Code:
    void plotTheDot( int i, int iFun )
    {
        cout << i << "   ";
        for( int n = 1; n<iFun; n++ ) cout << '#';
        cout << endl;
    }
    
    This will write the correct number of '#'s per row. hehe. You may want to normalize the number of '#'s to get a maximum of 70 or 80 (depending on your screen size). The result is somewhat like a histogram though. You have to look at the resulting plot, sideways.

    Why don't you use gnuplot instead?
     
  3. QuickSilver

    QuickSilver Corporal

    I guess if you wanted a nice graphical graph you are going to have to use some sort of graphics library specific to the platform you are hoping to run on. Each of these will have different implementations...
    What is your target platform and do you have any graphic libraries available?
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds