0

I am trying to use gnuplot directly from my C application under MacOSX in combination with Xcode. I downloaded the appropriate source files gnuplot_i.h and gnuplot_i.c (from here, version gnuplot_i-2.11) and included the header file. This all compiles just fine. I also checked if I had the newest version installed, which I appear to have:

[mycomputer:projectfolder]Me $ brew upgrade gnuplot
Error: gnuplot 5.0.3 already installed

In my application I just tried to use a simple example from the Documentation page (this one). The output is simply

sh: gnuplot: command not found

gnuplot_ctrl * g = gnuplot_init();

gnuplot_cmd(g, "set terminal png"); /* this outputs "sh: gnuplot: command not found" */
gnuplot_cmd(g, "set output \"/Users/Me/.../log/sine.png\"");
gnuplot_plot_equation(g, "sin(x)", "Sine wave");
gnuplot_close(g);

Does anyone have an idea, what could be the cause of the problem? I never used gnuplot before but I would love to. Right now I always need to write to a file and plot using MATLAB... I already read some posts here and this one might have a solution, but I am not sure how to replace the path in gnuplot_cmd() or if that's possible in the first place.

Does it have something to do with the fact that I am not on a Linux machine?

Thanks in advance :)

edit gnuplot is installed here:

[mycomputer:projectfolder]Me$ brew ls gnuplot
/usr/local/Cellar/gnuplot/5.0.3/bin/gnuplot
/usr/local/Cellar/gnuplot/5.0.3/libexec/gnuplot/5.0/gnuplot_x11
/usr/local/Cellar/gnuplot/5.0.3/share/gnuplot/ (36 files)
/usr/local/Cellar/gnuplot/5.0.3/share/man/ (2 files)
Community
  • 1
  • 1
meetaig
  • 913
  • 10
  • 26
  • Have you checked *where* the `gnuplot` command is installed? Maybe it's not in the standard path? – Some programmer dude Sep 05 '16 at 15:38
  • I updated my question, thanks for the hint. I suspect the `Cellar` is not the standard path? – meetaig Sep 05 '16 at 15:42
  • It most definitely isn't. :) So you either have to modify `gnuplot_i.c` to use an absolute path in the `gnuplot_init` function (in the call to `popen`), or make a symbolic link placed in a standard directory, or add the `/usr/local/Cellar/gnuplot/5.0.3/bin` directory to the path. – Some programmer dude Sep 05 '16 at 15:46
  • @JoachimPileborg That worked! Thanks a bunch! Make an actual answer out of this if you want, I will accept it ;) – meetaig Sep 05 '16 at 15:51

0 Answers0