[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

contour plots and doing graphics in octave

From: Donald J Bindner
Subject: contour plots and doing graphics in octave
Date: Wed, 28 Jan 2004 15:48:03 -0600
User-agent: Mutt/1.3.28i

I've looked at the code for doing contour plots in octave (both
version 2.0.x and 2.1.x) and both seem to be somewhat
problematic because they place what is effectively a 2-D object
into a 3-D context.

One deficiency of this is that you can't really draw on a contour
plot.  For example in a Calculus class it might desirable to draw
gradient vectors against the contours or show the path a particle
would take if it followed the gradient up to a maximum.

I have a modest alternative that generates good 2-D contour
plots from within Octave rather than leaving that jobs to gnuplot.
It is not as good as the current model in some cases, because I
used linear pieces, and the current code specifies bsplines, but
it is better because it isn't 3-D.

What I have done is the most obvious simple thing.  I interpolate
the function on a mesh of points (like returned my meshgrid) and
connect up the places that a contour would cross.  I dump these
line segments to files (one for each contour) and then ask
gnuplot to plot the file for each contour in a different color.

It works, so I know this can work pretty well and can be done
quickly.  But, at the moment, I'm calling gnuplot myself rather
than tying in with the graphics primitives already in Octave.
That means it is 2-D but I still can't draw on it.

My question in a nutshell is this.  From a dynamically linked
function, how do I create graphics?  There is a
send_to_plot_stream() in pt-plot.cc but its symbol is not
exported, except through the graw() function.  I see that there
are structures, tree_plot_command, etc., but I don't understand
what to do with them.  And I can't seem to trace from plot.m ->
__plt__.m --> __plt2__.m --> to the point where it interfaces
with the C++ code.

I attach my working-but-not-finished prototype so you can see
what context I come from.

Example usage:

 octave:1> r = linspace(0,1,50); t = linspace(0,2*pi,50);
 octave:2> [rr,tt] = meshgrid(r,t); xx = rr .* cos(tt); yy = rr .* sin(tt); zz 
= sqrt(1-rr.^2);
 octave:3> contour(xx,yy,zz)

Don Bindner <address@hidden>

Attachment: __cntr__.cc
Description: Text Data

Attachment: contour.m
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]