How to use Caca terminal of Gnuplot

Plot drawn using caca terminal of GNUPlot
Plot drawn using caca terminal of GNUPlot

Gnuplot can plot in ASCII at the terminal if the dumb terminal is chosen. However, this does not fully utilize the Unicode characters and color support of modern terminals. The Caca terminal of Gnuplot uses all the character and color capabilities of your terminal to generate beautiful and colorful plots. It does this by using the Caca library which provides these capabilities.

Build or Install

Gnuplot can be installed easily:

$ sudo apt install gnuplot

Note that support for caca terminal was added in Gnuplot 4.7. If you have that version and it was built with support for caca, then the commands in the next section should work directly.

If you do not have 4.7 and later and if it was not built with caca support, you need to build Gnuplot from source. Here are the steps I followed to build it from source:

  • Download Gnuplot source code from here and unzip it to a directory.

  • Install the Caca library if you do not have it already:

$ sudo apt install libcaca-dev
  • While building Gnuplot, I got an error in source files that use WxWidgets. To fix that, I opened the configure file, looked for the WX_CXXFLAGS option and appended -std=c++11 to its string.

  • While building Gnuplot, I got an error about linking with a X11 library. To fix that, I opened the configure file, looked for the WX_LIBS option and appended -lX11 to its string.

  • We are now ready to configure and build. Remember to configure with support for caca, since it is still an experimental feature and not enabled by default:

$ ./configure --with-caca
$ make
  • If the build is successful, you can install Gnuplot:
$ sudo make install

Usage

  • To use the caca terminal in Gnuplot:
gnuplot> set terminal caca

You can now plot anything and Caca draws it using ASCII/Unicode characters and colors.

  • You will notice that Caca opens a X window to draw the plot. If you would like it draw the plot in the terminal itself, then you need request caca to use a driver that can draw at the terminal.

  • You can view the list of drivers supported by caca:

gnuplot> set terminal caca driver list
  • Of these, the ncurses and slang drivers can draw to terminal. I found that using slang draws in color, but it shows lots of question mark symbols. So, I use ncurses:
gnuplot> set terminal caca driver ncurses

Now plot anything and view it in beautiful ASCII/Unicode and colors at the terminal!

  • You can find an extensive list of plots drawn using Caca here.

Tried with: Gnuplot 5.0.0, Caca 0.99.beta18 and Ubuntu 14.04

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s