if I understand well, you have a program producing data which usually are stored in a file, 
then you load such file into a matplotlib script. 

Your goal is trasfering data from your program to matplotlib.

If this is the case you  can follow two routes:
1) Modify the progam in order to print the information on standard output.
    Then, through the function popen, you execute your program into matplotlib, reading directly 
    the data without any external file.

2) if you cannot mpdify you program, you can execute in popen something like:
    program file.out; cat file.out.
    Again, your data are on the displayed on the standard output which is captured by popen


2012/4/27 Moore, Eric (NIH/NIDDK) [F] <eric.moore2@nih.gov>
> -----Original Message-----
> From: Ignas Anikevicius [mailto:anikevicius@gmail.com]
> Sent: Friday, April 13, 2012 4:25 PM
> To: matplotlib-users@lists.sourceforge.net
> Subject: [Matplotlib-users] Matplotlib and Cpp
> Dear all,
> I was wondering if it is possible to use matplotlib from C++ directly
> and I have found an example on how to do this on StackOverflow:
> http://stackoverflow.com/questions/2509156/anyone-knows-a-matplotlib-
> equivalent-in-c-or-c
> However, my question is about piping. Where could I find any tutorials
> on how to pipe data directly to matplotlib so that I would not need to
> right it to a file and then read it?
> Also, does matplotlib benefit from usage of cython and if it does, are
> there any things I should know before just trying to compile a
> matplotlib script with cython?
> All best,
> Ignas A.

You're trying to solve the wrong problem.  If you want to use matplotlib to show your results this way the easiest thing to do would be to rework so that python was the driver.  i.e wrap your C++ code so that a python program called it instead of trying to call python from C++.

The better solution here is probably to abandon matplotlib and use a plotting library that has C bindings.  One example is DISLIN, but I'm sure there are others (and don't take this as a recommendation.)


Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Matplotlib-users mailing list

Cordiali saluti, Dr.Oteri Francesco