help-octave
[Top][All Lists]
Advanced

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

Re: contour plot - still need help


From: Matthias Brennwald
Subject: Re: contour plot - still need help
Date: Wed, 05 Dec 2007 10:08:26 +0100
User-agent: Thunderbird 2.0.0.6 (X11/20071022)

Dear Foehn

Octave isn't exactly the best tool for this, but I tend to use Octave for most of my plots, too. The below code does much of what you want, but I'm not proud of it (its poor Octave/Matlab style):

---------------------
clear all; close all;
[x,y]=meshgrid(linspace(-2,+2,100),linspace(-2,+2,100));
z=exp(-(x.*x+y.*y));
vn=[0:0.05:+2]; # vector with isolines

% compute and plot the contour lines, clear the plot afterwards
c = contour(x,y,z,vn); clf

% replot as desired
i = 0;
while i(end) < size(c,2)
        lev = c(1,i(end)+1);
        len = c(2,i(end)+1);
        i = [i(end)+2:i(end)+len+1];
        if ~rem(lev,0.2)
                h = plot(c(1,i),c(2,i),'k-');
                set(h,'linewidth',1.5);
                t = text(0,min(c(2,i))-0.065,sprintf('%g',lev));
                set(t,'horizontalalignment','center');
        else
                h = plot(c(1,i),c(2,i),'k.');
                set(h,'linewidth',0.5);
        end
        hold on
end

axis ([-2, +2, -2, +2], "square");
grid on;
title("2D-Gaussian Bell Function");
xlabel("x");ylabel("y");
print ("cont.eps","-depsc")
---------------------

Cheers
Matthias

--
Matthias Brennwald
Project Manager Safety Analysis
Hardstrasse 73
5430 Wettingen
Switzerland
+41 56 437 13 32


reply via email to

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