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)
  • 2
    Can you say more specifically what isn't working? Perhaps the commands you are using, error messages, and results?
    – Scot
    Commented Sep 30, 2013 at 16:55
  • 1
    when I want to plot sin(x) in gnuplot, it can not plot and it goes to the next line without any error. $gnuplot >plot sin(x) >
    – Soheil
    Commented Sep 30, 2013 at 17:35
  • Please edit the pertinent details into the body of the question. Comments get cleared from time to time and we'd hate to lose the problem when that happens here.
    – bmike
    Commented Sep 30, 2013 at 17:36
  • 1
    How exactly did you install it?
    – mmmmmm
    Commented Sep 30, 2013 at 19:32
  • Does xterm give you a xterminal ?
    – mmmmmm
    Commented Sep 30, 2013 at 19:33

6 Answers 6


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.

  • 1
    Maybe I'm slow today, but I spent a good 15 minutes in the gnuplot docs looking for a simple example like this .. or maybe the docs make some assumptions about the audience and I'm not one of them :)
    – Jared Beck
    Commented Oct 23, 2014 at 2:17
  • 6
    xQuartz is heavy and somehow homebrew doesn't package it. I went with --qt option instead bew install gnuplot --qt and it works fine now. Commented Oct 28, 2014 at 23:09
  • 3
    Option name has changed to --with-x11 but I cannot make an edit of only two characters.
    – mgd
    Commented Dec 8, 2014 at 9:22
  • 1
    Note that sometimes you need to log out and log back in after installing XQuartz. (don't know why, but it didn't set the $DISPLAY variable correctly until I logged out) Also, very useful to install XQuartz is caskroom.io: brew cask install xquartz
    – caesarsol
    Commented Apr 15, 2015 at 10:01
  • doesn't work for OS X Yosemite Commented Sep 21, 2015 at 14:26

In OS X Yosemite 10.10.2 and El Capitan 10.11.2, the Gnuplot does not package with XQuartz. Answer in bibstha's comment. Much more robust window manager is in qt and it works

 brew uninstall gnuplot
 brew install gnuplot --with-qt

Note that using --qt is deprecated now.

  • Just as a side note, Warning: gnuplot: --qt was deprecated; using --with-qt instead!
    – vitaly
    Commented Feb 26, 2015 at 7:03
  • @vitaly Interesting. I did not get that warning or I ignored. I changed the command. Commented Feb 26, 2015 at 10:24
  • --qt must have been valid at some point and then it was deprecated
    – vitaly
    Commented Feb 28, 2015 at 1:04
  • 1
    Why not to choose both: brew install gnuplot --with-qt --with-x11.
    – kenorb
    Commented Dec 6, 2015 at 16:49
  • Because of the bug having X11 in Yosemite. Not using at the moment Yosemite so cannot test with the latest update. Commented Dec 6, 2015 at 17:31

Are you running this from a Terminal window, or an X11 window? The terminal will launch X11 separately to show the plot, so it may not be immediate (or visible). Does X11 get launched at all when you type your plot command?

If you try it in an X11 window, the result should be more immediate.

Also, if you used macports to install it originally, I would recommend using homebrew instead:

brew install gnuplot

EDIT: To check where the output is going, you could direct your results to a file:

set terminal png
set output 'testimage.png'
plot sin(x)

Then see if a file called testimage.png contains your plot. You could also try specifying the terminal with:

set terminal x11
  • Yes, you are right and the last > is not part of my command. Moreover, I am running from a both Terminal window and X11 window separately, but none of them could plot.
    – Soheil
    Commented Sep 30, 2013 at 18:56
  • Then I would try reinstalling with brew. It is hard to diagnose without knowing more about your installation.
    – beroe
    Commented Sep 30, 2013 at 19:02
  • (Updated answer with another thing to test...)
    – beroe
    Commented Sep 30, 2013 at 19:08
  • Why does replacing macports by brew make a difference they both work - both much better than doing on your own
    – mmmmmm
    Commented Sep 30, 2013 at 19:31
  • In my experience I have problems with libraries and dependencies when I use macports, so have stopped doing so...
    – beroe
    Commented Sep 30, 2013 at 21:05

In Yosemite, Initially, I had quartz and gunplot 5.0.0 installed. However, I could not load my x11 window (everything else was file-X11 was somehow unknown). Here is a workaround that 'worked for me'.

Go to the gunplot source folder

make clean; 
make uninstall

then in the "configure" file under the following lines

# Standard set of common directories for X headers.

# Check X11 before X11Rn because it is often a symlink to the current release.

---added the location of my X11 files also  

now run

sudo make install

worked perfectly for me as you see below

Version 5.0 patchlevel 0    last modified 2015-01-01 

Copyright (C) 1986-1993, 1998, 2004, 2007-2015
Thomas Williams, Colin Kelley and many others

gnuplot home:     http://www.gnuplot.info
faq, bugs, etc:   type "help FAQ"
immediate help:   type "help"  (plot window: hit 'h')

Terminal type set to 'x11'.

  • How did you install X11 /opt is not usual I think
    – mmmmmm
    Commented Mar 8, 2015 at 16:27

Thanks. After downloading gunplot 5.0 and installing under Yosemite 10.10.2, gnuplot couldn't "load" the x11 terminal. After pointing the configure file to /opt/X11/include (reconfiguring, remaking, and reinstalling) every worked fine. (I was surprised, too, that X11 is in /opt/X11.)

  • Why not use a quartz backend rather than X11
    – mmmmmm
    Commented Apr 12, 2015 at 1:57

Most of the advice here shows how to install/reinstall GNUPlot via brew. If you have an installation of GNUPlot and are unsure what terminal its using you can determine this like so:

$ gnuplot <<<'show terminal'

   terminal type is qt 0 font "Sans,9"

At which point we now know we're using the qt terminal type. With thin information now in hand you can decide on which course of action to take, either following one of the other answers to re-install GNUPlot via brew or configuring your existing terminal in whatever way you want via the set terminal .... . command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .