X-Received: by 10.129.72.205 with SMTP id v196mr14398854ywa.11.1444470344553; Sat, 10 Oct 2015 02:45:44 -0700 (PDT) X-Received: by 10.182.148.40 with SMTP id tp8mr104927obb.37.1444470344468; Sat, 10 Oct 2015 02:45:44 -0700 (PDT) Path: csiph.com!xmission!news.glorb.com!z77no8701790qge.1!news-out.google.com!n2ni25923igy.0!nntp.google.com!kq10no19276623igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.graphics.apps.gnuplot Date: Sat, 10 Oct 2015 02:45:44 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=188.174.95.19; posting-account=Epj3_QoAAADuDu9ZU_6s-axcdUkMqNAW NNTP-Posting-Host: 188.174.95.19 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: set parameters in gnuplot using c++ source code From: Marcello Chiurazzi Injection-Date: Sat, 10 Oct 2015 09:45:44 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.graphics.apps.gnuplot:3102 Hi I'm trying to plot some vectors using gnuplot from a c++ source code.I already read a question about how to interface c++ with the gnuplot. This is the source code: int main() { char * commandsForGnuplot[] = {"set title \"Trajectory_ARM\"","plot 'data.temp' with linespoints"}; double xvals[NUM_POINTS] = {1.0, 2.0, 3.0, 4.0, 5.0}; double yvals[NUM_POINTS] = {5.0 ,3.0, 1.0, 3.0, 5.0}; FILE * temp = fopen("data.temp", "w"); /*Opens an interface that one can use to send commands as if they were typing into the * gnuplot command line. "The -persistent" keeps the plot open even after your * C program terminates. */ FILE * gnuplotPipe = popen ("gnuplot -persistent", "w"); int i; for (i=0; i < NUM_POINTS; i++) { fprintf(temp, "%lf %lf \n", xvals[i] , yvals[i]); //Write the data to a temporary file } for (i=0; i < NUM_COMMANDS; i++) { fprintf(gnuplotPipe, "%s \n", commandsForGnuplot[i]); //Send commands to gnuplot one by one. } return 0; } The problem is: if I have a new vector of 5 points(A) and I want to have in the same plot A and xvals in respect of yvals? How I should modify my code? In this case I would like to plot A and xvals with two different colors. Thanks in advance!