MacOS – Can’t plot with gnuplot on the Mac

displaymacosopen sourcex11

I am trying to plot with gnuplot on my Mac (OS X 10.8.5). I have installed X11 and XQuartz 2.7.4 and after that I installed gnuplot, but unfortunately gnuplot couldn't plot.

Simple plots like the following fail to render and have no error message to help understand what is amiss:

 [1/10/13 $gnuplot >plot sin(x)

Best Answer

The same thing happened to me, but then I ran

brew uninstall gnuplot; brew install gnuplot --with-x11

and installed XQuartz. Now gnuplot supports the x11 terminal:

You can also save the output to a file and use qlmanage -p:

gnuplot -e 'set term png; set output "/tmp/plot.png"; plot sin(x)'; qlmanage -p /tmp/plot.png

qlmanage -p shows a sandboxing error in 10.9 and prints some unnecessary text to STDOUT, so I use a function like ql() { qlmanage -p "$@"&>/dev/null; } in shells.

A third option is to use set term dumb for plain text output.