???Graphs and plotting in C++???
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: ???Graphs and plotting in C++???

  1. #1
    Join Date
    Sep 2011
    Posts
    7

    ???Graphs and plotting in C++???

    I see that there are several C++ libraries which can be used to plot data... However, I can't seem to find one that isn't out of date. I've managed to get all the data I need using Visual C++ 2010, but I can't plot it :0 lol...

    *koolplot
    *gnnuplot++
    *ch plot

    I have googled away, but I'm still stuck on the plotting part. There is always the option to send data to Excel or Matlab... but honestly I want to go for a relatively simple approach (if there is one). Most of what I want to plot relates to stock price data and volatility. Any suggestions on the best way to learn plotting in Visual C++?

    Cheers
    You can just hang outside in the sun all day tossing a ball around. Or you can sit at your computer and do something that matters...

  2. #2
    Join Date
    Apr 1999
    Posts
    27,424

    Re: ???Graphs and plotting in C++???

    Quote Originally Posted by Zaf View Post
    I see that there are several C++ libraries which can be used to plot data... However, I can't seem to find one that isn't out of date.
    http://www.gnuplot.info/

    According to this, the latest version is 4.6. It was released just a few months ago.

    Any suggestions on the best way to learn plotting in Visual C++?
    What do you mean by "learn plotting"? C++ is a general computer language, and Visual C++ is the brand of C++ compiler created by Microsoft. So how does your question fit?

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Sep 2011
    Posts
    7

    Re: ???Graphs and plotting in C++???

    I need to be able to produce graphs using something like gnuplot (though I'm open to suggestions), but automated through Visual C++ 2010. I have tried using gnuplot++ (http://www.suiri.tsukuba.ac.jp/~asanuma/gnuplot++/) but I haven't been getting any love from it.

    My basic question is this:
    1) Has someone here been successfully able to automate the production of graphs through Visual C++ (either by calling on something like gnuplot, matlab, or anything else)?

    2)What is the most simple (hopefully) way to automate the production of these graphs?

    Cheers
    You can just hang outside in the sun all day tossing a ball around. Or you can sit at your computer and do something that matters...

  4. #4
    Join Date
    Apr 1999
    Posts
    27,424

    Re: ???Graphs and plotting in C++???

    Quote Originally Posted by Zaf View Post
    I need to be able to produce graphs using something like gnuplot (though I'm open to suggestions), but automated through Visual C++ 2010. I have tried using gnuplot++ (http://www.suiri.tsukuba.ac.jp/~asanuma/gnuplot++/) but I haven't been getting any love from it.
    It would help if you told us what the problems is. The samples look very straightforward to me, and I've never used gnuplot.
    1) Has someone here been successfully able to automate the production of graphs through Visual C++ (either by calling on something like gnuplot, matlab, or anything else)?
    Of course persons have used gnuplot and Matlab in their C/C++ programs. The real issue is that we have no idea what your level of expertise in programming is.

    Any of these libraries you mention assume that as a prerequisite, you know the C or C++ language -- not in passing, but actually know how to use it. If you only have limited knowledge of these languages, then no API is going to help you.

    For example, my company creates API's to interface to scanners, and the problem we have many times is that the persons using our API's do not know C or C++ language well enough to use the API's properly.

    Regards,

    Paul McKenzie

  5. #5
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,564

    Re: ???Graphs and plotting in C++???

    I do not know of an official gnuplot API callable from C/C++ ...

    One way that I have used ...

    Your code creates a file that contains the gnuplot commands ... then
    use ShellExecute ...

    Code:
    ::ShellExecute(NULL,"open","wgnuplot.exe","c3m_gnuplot.txt -",NULL,SW_SHOWDEFAULT);
    I believe that you can also use pipes, but I have not done this.

  6. #6
    Join Date
    Sep 2011
    Posts
    7

    Re: ???Graphs and plotting in C++???

    Thanks for your replies. I will give the shell execute command a try - looks promising :-) I am just learning C++. Usually I code in VBA - gathering data from a database or the internet, running calculations and then doing some plots of the results.

    The plotting is really what I found hard - basically because I'm not sure where to start with the plotting and want to go with the most efficient approach - looking for pointers I guess :-)

    I've executed APIs in VBA before - mostly the urldownloadtofile, shellexecute and the like - but I can't say that I have an in depth knowledge of them.

    Cheers.
    You can just hang outside in the sun all day tossing a ball around. Or you can sit at your computer and do something that matters...

  7. #7
    Join Date
    Sep 2011
    Posts
    7

    Re: ???Graphs and plotting in C++???

    Thanks a million for your help guys. You definately saved me a lot of time.

    Here is a basic example that uses C++ to run a gnuplot script (plotting sin(x)) and saves the plot to my desktop as a png image.

    Code:
    #include "stdafx.h"
    #include <Windows.h>
    
    int main()
    {
    //The file "RunThisScript.txt" contains the following:
    
    //set term png
    //set output 'C:\Users\Simon\Desktop\ThisOutput.png'
    //plot sin(x)
    //quit
    
    ShellExecute(NULL, L"open", L"C:\\Program Files (x86)\\gnuplot\\bin\\wgnuplot.exe", \
    		L"C:\\Users\\Simon\\Desktop\\RunThisScript.txt", NULL, SW_SHOWNORMAL); 
    
    	return 0;
    }
    Cheers
    You can just hang outside in the sun all day tossing a ball around. Or you can sit at your computer and do something that matters...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center