AIMS computer tips from David MacKay


| Window manager | Gnuplot | Octave |

Graph colours in gnuplot and octave

I like my octave graphs to be coloured red, orange, yellow, green, blue.... on a black background. To make this happen, I have a file called .Xdefaults in my home directory. This file changes the behaviour of any octave or gnuplot program I run during my Xsessions. To copy this colour scheme, try copying over my commands like this
 grep gnuplot ~mackay/.Xdefaults >> ~/.Xdefaults
Then either start a new Xsession, or type
 xrdb < ~/.Xdefaults

Window manager tips

Several of my programs use gnuplot and make many plots. If you are using the default IceWM configuration then you may find this annoying since while the plots are coming up, you will be unable to use your computer for anything other than watching the plots. Your window manager keeps on giving the "focus" to the Gnuplot window!

In my opinion, this window manager behaviour is silly. There are two ways to fix it.

David's method

$ mkdir ~/.icewm ; cp ~mackay/.icewm/*  ~/.icewm

If you already have a directory called ~/.icewm, please move the directory to ~/.icewm.bak first; then you can restore your original configuration, if you dislike mine, by typing rm -r ~/.icewm, and moving the directory back.

Edit the preferences file in ~/.icewm if you want to change the preferences from the way I have them.

Jan's elegant method

Another way to change the new windows popping up and taking over the keyboard and mouse focus, but without losing all your other personal settings, is this command:

$ mkdir ~/.icewm; echo FocusOnAppRaise=0>>~/.icewm/prefoverride
It uses an override file rather than a whole new preferences file.

Note that this means when you launch viewers from email, web or command line, you will have to click on them to focus.


| Window manager | Gnuplot | Octave |

gnuplot tips

Typing ? gives help;

?plot
gives help on plot.

How to achieve looping in a gnuplot demonstration.

 gnuplot> help reread
to find out how.

Here is an example:

 Suppose the file "looper" contains the commands
       a=a+1                                    
       plot sin(x*a)
       pause -1     
       if(a<5) reread
 and from within `gnuplot` you submit the commands
       a=0                                        
       load 'looper'
 The result will be four plots (separated by the `pause` message).

For further gnuplot examples,

$ cd /usr/share/doc/gnuplot-doc/examples
$ ls                                      NOTE the files *dem
$ gnuplot
>   load 'mgr.dem'
>   load 'electron.dem'
>   load other .dem files



| Window manager | Gnuplot | Octave |

Octave

How to load data from a file into octave

If you have some numbers in data.txt, then

octave>  a = load data.txt

will put all those numbers into a matrix called a.

octave>  help load

gives full information.

Images

How to read in an image into octave:

 img=imread("jam.jpg")

How to display an image:

image(img,1)