Wednesday, May 23, 2007

Trick to change octave's plot background

Well, I was trying to change octave's plot background, but I found no easy way, so I changed the way gnuplot is called (gnuplot is the program octave calls to plot the graphics). Simply go to /usr/bin, log as root, and backup gnuplot as
cp gnuplot gnuplot.bak

Rename it to gnuplot1:
mv gnuplot gnuplot1

Now create the script gnuplot by typing
emacs gnuplot

Create this script:

#!/bin/bash
/usr/bin/gnuplot1 -background white

Add execution permission through chmod +x gnuplot

It will make a standard call to gnuplot change to gnuplot -background white, which will change your plots background in octave.
If you have a better way to do this, please leave me a comment
Have fun :)

6 comments:

  1. Anonymous1:56 PM

    It's so simple, am kicking myself now. Nice one. Thanks.

    ReplyDelete
  2. Anonymous1:33 PM

    Hi Daniel,

    It's a good idea. Work when I type figure on octave (an withe bkground figure appears), but when a try to plot, type plot(x), the command line go to gnuplot prompt.

    And a message is showed:

    Terminal type set to 'wxt'

    Additional information:
    distro: debian
    octave 2.9
    gnuplot 4.2

    Any idea?

    Henrique

    ReplyDelete
  3. Anonymous5:57 PM

    http://staticwiki.ubuntuusers.de/Gnuplot

    ReplyDelete
  4. Anonymous5:49 PM

    The "correct" way to do it is to specify the X resource for Gnuplot's background.

    # do this once
    echo "gnuplot*background: lavender" >> ~/.Xresources

    # do this on login
    xrdb -merge ~/.Xresources

    ReplyDelete
  5. Anonymous7:52 AM

    This comment has been removed by a blog administrator.

    ReplyDelete
  6. I found that the .Xresources trick worked when invoking gnuplot directly, but did not work when octave invoked gnuplot. However, the following worked in octave 3.4.3:

    set(gcf, 'color', [0 0 0]) # to set to black

    ReplyDelete