Showing posts with label gnuplot. Show all posts
Showing posts with label gnuplot. Show all posts

Friday, October 29, 2010

Zooming in GNU Octave under Ubuntu

Yay, I finally solved my problem! I can now zoom in Octave plots using the mouse (currently on Ubuntu 10.04 LTS).


...but here it is so you don't have to scroll through all of that:

Build gnuplot with:
./configure --enable-volatile-data
make
sudo make install

and if necessary change the gnuplot's path in octave with:
gnuplot_binary ("/usr/local/bin/gnuplot") 





Just use the right mouse button to select the first point, then click a second time to select the other corner. Whala! Press "a" to go back to the original zoom level, and press "h" to dump some help out to the Octave terminal window.

Enjoy!

Saturday, January 30, 2010

GNU Plot and Octave

Octave is a MatLab-compatible interpreter, which uses Gnuplot to display graphics. I'll now show you how to capture the commands sent from Octave to Gnuplot. This is useful for learning how to drive Gnuplot, among other uses.

First, launch Octave, and then enter the following command:

octave> plot(sin(0:0.1:30),'LineWidth',3)

You can now regenerate this plot, but direct the plotting commands to a file:

octave> drawnow("svg", "drawing.svg", false, "drawing.gp")

In this case, we've chosen the SVG "terminal", so that a scalable-vector-graphics image is created in the current directory. The Gnuplot commands used to create this image can be found in the drawing.gp file.

Here's the drawing.svg image:

(blogger.com wouldn't actually let me upload an .svg, so I had to render it to a .png first, but you get the idea)

In another terminal window, you can feed the Gnuplot commands to Gnuplot, to recreate this image:

> gnuplot drawing.gp

If you don't want to create an image file, but instead want to view the image in a window, do this instead:

octave> drawnow("x11", "/dev/null", false, "drawing.gp")

Then launch Gnuplot, and enter this command:

gnuplot> load 'drawing.gp'

Whala!