🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #15006

Re: Mandar datos de un programa a otro

#15006
From: eloy
Date: Thu, 24 Aug 2000 00:00
56 lines
2784 bytes
On 23 Aug 2000, Raúl (Ridiculum) wrote:

> 	Estoy haciendo un programa que requiere que los resultados obtenidos se
> 	visualicen en una gráfica. Para esto voy a usar gnuplot. El problema
> 	viene a la hora de pasarle los datos y como quiero que los represente
> 	(ejes logaritmicos, nombre de los ejes, color, ....)
> 
> 	¿como se le pasan desde mi programa esos datos al gnuplot?
> 

	Yo lo tengo hecho así:

---------------------
void T1GraphPopulation(POPULATION *pop, int last)
        {
        static FILE *p=NULL;
        int i;

        wlog("graphing population: %d individuals", pop->size );
        
        if( p==NULL ) {
                p= popen( "/usr/bin/gnuplot -geometry 600x450+192+0",
			"wt" );
                if( p==NULL ) {
                        perror( "Opening gnuplot: ");
                        exit(1);
                        }
                }
                
        fprintf( p, "plot [-2:2] [-2:2] 1-sqrt(x), \'-\' "
                "title \"gen %d\"\n", pop->generation );
        for( i=0 ; i<=pop->size-1 ; i++ ) 
                fprintf( p, "%f %f\n",
                        pop->individuals[i]->objectives[0],
                        pop->individuals[i]->objectives[1]);
        fprintf( p, "e\n" );
        fflush(p);
        
        if(last) {
                wlog("PRESS ENTER");
                getchar();
                fclose(p);
                }
        }
------------------------

	Espero que ayude. Suerte


                                        -- Eloy
_____________________________________________________________________
---- Eloy Rafael Sanz Tapia -- ersanz@uco.es -- ma1satae@uco.es -----
------------------ http://www.uco.es/~ma1satae ----------------------
----------- GPG ID: 190169A0 / finger eloy@rabinf50.uco.es ----------
Córdoba _ España _______________ Debian 2.1 GNU/Linux 2.2.16 rabinf50
Technical Details
Message-ID: <Pine.LNX.4.21.0008241924360.26614-100000@eloy.ayrna.org>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <slrn8q7t65.is.Ridiculum@localname.localdomain>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,ba997d003fbe7a00
X-Google-Attributes: gidf86c8,public
From: eloy <eloy@rabinf50.uco.es>
Subject: Re: Mandar datos de un programa a otro
Date: 2000/08/24
Message-ID: <Pine.LNX.4.21.0008241924360.26614-100000@eloy.ayrna.org>
X-Deja-AN: 662045165
Content-Transfer-Encoding: QUOTED-PRINTABLE
References: <slrn8q7t65.is.Ridiculum@localname.localdomain>
To: "Raúl (Ridiculum)" <Ridiculum@bionichat.com>
Content-Type: TEXT/PLAIN; charset=iso-8859-1
X-Complaints-To: news@cica.es
X-Trace: mercurio.cica.es 967137903 3302 150.214.117.180 (24 Aug 2000 17:25:03 GMT)
Organization: C.I.C.A.
Mime-Version: 1.0
Reply-To: ersanz@uco.es
NNTP-Posting-Date: 24 Aug 2000 17:25:03 GMT
Newsgroups: es.comp.os.linux.programacion