[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: contour plot - still need help
From: |
Foehn |
Subject: |
Re: contour plot - still need help |
Date: |
Sat, 08 Dec 2007 16:41:47 +0100 |
User-agent: |
Thunderbird 1.5.0.14pre (X11/20071022) |
Hi Matthias,
thank you for your example. It helps me at least with labelling, and
gives a hint how to proceed further.
Regards,
Foehn
Matthias Brennwald schrieb:
> 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
>
>