Skip to content

Instantly share code, notes, and snippets.

@Hajto
Created November 1, 2016 19:54
Show Gist options
  • Save Hajto/6f8c0e40d193b03f0fe70891b0f6fee5 to your computer and use it in GitHub Desktop.
Save Hajto/6f8c0e40d193b03f0fe70891b0f6fee5 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
#include <stdio.h>
#define NUM_POINTS 5
#define NUM_COMMANDS 2
int main()
{
char * commandsForGnuplot[] = {"set title \"TITLEEEEE\"", "plot 'data.temp'"};
double xvals[NUM_POINTS] = {1.2, 2.0, 3.0, 4.0, 4.5};
double yvals[NUM_POINTS] = {4.8 ,3.0, 1.0, 3.0, 3.23};
FILE * gnuplotPipe = popen ("gnuplot -persistent", "w");
fprintf(gnuplotPipe, "plot '-' \n");
int i;
for (int i = 0; i < NUM_POINTS; i++)
{
fprintf(gnuplotPipe, "%lf %lf\n", xvals[i], yvals[i]);
}
fprintf(gnuplotPipe, "e");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment