I installed gnuplot on my Macbook with Catalina 10.15.13. When I use it in Xcode it does not show me anything, it provides
WARNING: Plotting with an 'unknown' terminal.
No output will be generated. Please select a terminal with 'set terminal'.
Having said that, I saw that to plot data I would need of the terminals qt or x11 which I do not have. The questions are two:
How can I install them? homebrew does not allow me to use brew "install gnuplot --with-x11"
In order to see the data, Do I have to need of this two terminals? Can't I use another one?
What I'm asked to do is to call gnuplot inside my program, and not controlling it from the terminal. It works, but it does not keep thw window with chart open. Inside utils.h there are some function and the structure instance, but it does not have nothing to do with gnuplot. My code is:
#include "utils.h"
#include <stdio.h>
char* commandsForGnuplot[] = {
"set style increment default",
"set title 'Simple Plots'",
"set title font ',20' norotate",
"set xrange[*:*] noreverse writeback",
"set x2range[*:*] noreverse writeback",
"set yrange[*:*] noreverse writeback",
"set y2range[*:*] noreverse writeback",
"set zrange[*:*] noreverse writeback",
"set cbrange[*:*] noreverse writeback",
"set rrange[*:*] noreverse writeback",
"plot[-pi / 2:pi] cos(x), -(sin(x) > sin(x + 1) ? sin(x) : sin(x + 1))"
};
int main(int argc, const char * argv[]) {
int n_commands = 11;
if ( argc < 2 ) { printf("Usage: %s -help for help\n", argv[0]); exit(1); }
if ( VERBOSE >= 2 ) { for (int a = 0; a < argc; a++) printf("%s ", argv[a]); printf("\n"); }
instance inst;
//////////////////////////////////////////////////////////
// Parse the command line
//////////////////////////////////////////////////////////
parse_command_line(argc,argv, &inst);
//printf(" file %s has %d non-empty lines\n", inst.input_file, number_of_nonempty_lines(inst.input_file)); exit(1);
//////////////////////////////////////////////////////////
// Parse the input file
//////////////////////////////////////////////////////////
read_input(&inst);
// if ( VRPopt(&inst) ) print_error(" error within VRPopt()");
// debug print
instance_tostring(&inst);
FILE* gnuplotPipe = popen("/usr/local/bin/gnuplot", "w");
if (!gnuplotPipe) { perror("popen gnuplot"); exit(EXIT_FAILURE); };
for (int i = 0; i < n_commands; i++)
{
fprintf(gnuplotPipe, "%s \n", commandsForGnuplot[i]);
printf("%s \n", commandsForGnuplot[i]);
}
pclose(gnuplotPipe);
return 0;
}