question about contourf command

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

question about contourf command

Tso-Min Chou
Hi,
I did the 2D filled contour plot with both Octave and Matlab with same script file; but the filled contour plots are very different. I also checked the data file and they are the same.

The following plot is from Octave
image.png

This one is from Matlab
image.png

And here is my script file run in both Octave and Matlab.
data = importdata('error_demo_2.txt') ;  % read file 
x = data(:,1); 
y = data(:,2); 
z = data(:,3); 
% Grid 
%x0 = min(x) ; x1 = max(x) ;
%y0 = min(y) ; y1 = max(y) ;
%N = 10 ;
%x2 = linspace(x0,x1,N) ; 
%y2 = linspace(y0,y1,N) ; 
%[X,Y] = meshgrid(x2,y2) ;
[X,Y] = meshgrid(sort(x),sort(y));
Z = griddata(x,y,z,X,Y,'linear');
figure (1)
contourf(X,Y,Z);
colormap ('jet')
colorbar
figure (2)
meshc(X,Y,Z)
colormap ('jet')
colorbar
figure (3)
contour(X,Y,Z);
%meshc(X,Y,Z)
colormap ('jet')
colorbar
xlabel ('Vds')
  ylabel ('Ids(mA/mm)')
  title ('S11 VAEerr')

Anyone can tell me what is the reason for the difference and how to solve it?

Thanks,

TM



Reply | Threaded
Open this post in threaded view
|

Re: question about contourf command

Doug Stewart-4


On Mon, Sep 17, 2018 at 9:24 AM Tso-Min Chou <[hidden email]> wrote:
Hi,
I did the 2D filled contour plot with both Octave and Matlab with same script file; but the filled contour plots are very different. I also checked the data file and they are the same.

The following plot is from Octave
image.png

This one is from Matlab
image.png

And here is my script file run in both Octave and Matlab.
data = importdata('error_demo_2.txt') ;  % read file 
x = data(:,1); 
y = data(:,2); 
z = data(:,3); 
% Grid 
%x0 = min(x) ; x1 = max(x) ;
%y0 = min(y) ; y1 = max(y) ;
%N = 10 ;
%x2 = linspace(x0,x1,N) ; 
%y2 = linspace(y0,y1,N) ; 
%[X,Y] = meshgrid(x2,y2) ;
[X,Y] = meshgrid(sort(x),sort(y));
Z = griddata(x,y,z,X,Y,'linear');
figure (1)
contourf(X,Y,Z);
colormap ('jet')
colorbar
figure (2)
meshc(X,Y,Z)
colormap ('jet')
colorbar
figure (3)
contour(X,Y,Z);
%meshc(X,Y,Z)
colormap ('jet')
colorbar
xlabel ('Vds')
  ylabel ('Ids(mA/mm)')
  title ('S11 VAEerr')

Anyone can tell me what is the reason for the difference and how to solve it?

Thanks,

TM



What version of Octave are you using?
What OS?
Any packages installed? 


--
DAS



Reply | Threaded
Open this post in threaded view
|

Re: question about contourf command

Pantxo
In reply to this post by Tso-Min Chou
Tso-Min Chou wrote

> Hi,
> I did the 2D filled contour plot with both Octave and Matlab with same
> script file; but the filled contour plots are very different. I also
> checked the data file and they are the same.
>
> The following plot is from Octave
> [image: image.png]
>
> This one is from Matlab
> [image: image.png]
>
> And here is my script file run in both Octave and Matlab.
> data = importdata('error_demo_2.txt') ;  % read file
> x = data(:,1);
> y = data(:,2);
> z = data(:,3);
> % Grid
> %x0 = min(x) ; x1 = max(x) ;
> %y0 = min(y) ; y1 = max(y) ;
> %N = 10 ;
> %x2 = linspace(x0,x1,N) ;
> %y2 = linspace(y0,y1,N) ;
> %[X,Y] = meshgrid(x2,y2) ;
> [X,Y] = meshgrid(sort(x),sort(y));
> Z = griddata(x,y,z,X,Y,'linear');
> figure (1)
> contourf(X,Y,Z);
> colormap ('jet')
> colorbar
> figure (2)
> meshc(X,Y,Z)
> colormap ('jet')
> colorbar
> figure (3)
> contour(X,Y,Z);
> %meshc(X,Y,Z)
> colormap ('jet')
> colorbar
> xlabel ('Vds')
>   ylabel ('Ids(mA/mm)')
>   title ('S11 VAEerr')
>
> Anyone can tell me what is the reason for the difference and how to solve
> it?
>
> Thanks,
>
> TM
>
>
>
>
> image.png (41K)
> &lt;http://octave.1599824.n4.nabble.com/attachment/4689419/0/image.png&gt;
> image.png (25K)
> &lt;http://octave.1599824.n4.nabble.com/attachment/4689419/1/image.png&gt;

Hi,

You did not attache the input file so that it is impossible for us to
reproduce and eventually diagnose this origin of the issue.
Could attach 'error_demo_2.txt'?

Pantxo



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: question about contourf command

Doug Stewart-4
In reply to this post by Doug Stewart-4


On Mon, Sep 17, 2018, 1:27 PM Tso-Min Chou, <[hidden email]> wrote:
Doug,

It's V4.4.0 for windows. Just standard no extra packages.

Tso-Min

Keep the list informed 



On Mon, Sep 17, 2018 at 9:51 AM Doug Stewart <[hidden email]> wrote:


On Mon, Sep 17, 2018 at 9:24 AM Tso-Min Chou <[hidden email]> wrote:
Hi,
I did the 2D filled contour plot with both Octave and Matlab with same script file; but the filled contour plots are very different. I also checked the data file and they are the same.

The following plot is from Octave
image.png

This one is from Matlab
image.png

And here is my script file run in both Octave and Matlab.
data = importdata('error_demo_2.txt') ;  % read file 
x = data(:,1); 
y = data(:,2); 
z = data(:,3); 
% Grid 
%x0 = min(x) ; x1 = max(x) ;
%y0 = min(y) ; y1 = max(y) ;
%N = 10 ;
%x2 = linspace(x0,x1,N) ; 
%y2 = linspace(y0,y1,N) ; 
%[X,Y] = meshgrid(x2,y2) ;
[X,Y] = meshgrid(sort(x),sort(y));
Z = griddata(x,y,z,X,Y,'linear');
figure (1)
contourf(X,Y,Z);
colormap ('jet')
colorbar
figure (2)
meshc(X,Y,Z)
colormap ('jet')
colorbar
figure (3)
contour(X,Y,Z);
%meshc(X,Y,Z)
colormap ('jet')
colorbar
xlabel ('Vds')
  ylabel ('Ids(mA/mm)')
  title ('S11 VAEerr')

Anyone can tell me what is the reason for the difference and how to solve it?

Thanks,

TM



What version of Octave are you using?
What OS?
Any packages installed? 


--
DAS



Reply | Threaded
Open this post in threaded view
|

Re: question about contourf command

Pantxo
In reply to this post by Pantxo
Le 17/09/2018 à 19:28, Tso-Min Chou a écrit :

Hi,

You did not attache the input file so that it is impossible for us to
reproduce and eventually diagnose this origin of the issue.
Could attach 'error_demo_2.txt'?

Pantxo



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Forwarding your email and the data file.

The Z output contains NaN in regions where no (x,y) pair was provided and Octave doesn't seem to handle those well.

A workaround is to replace NaN values by some value lower than the min value and and fix the countour levels by hand. Something like

data = importdata('error_demo_2.txt') ;  % read file 
x = data(:,1); 
y = data(:,2); 
z = data(:,3);

[X,Y] = meshgrid(sort(x),sort(y));
Z = griddata(x,y,z,X,Y,'linear');

figure (1)
minz =
min (Z(:));
maxz = max (Z(:));
Z(isnan (Z)) =
minz - (maxz - minz) /2;
[~, h] = contourf(X,Y,Z, linspace (minz, maxz, 10));

Pantxo



error_demo_2.txt (574 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: question about contourf command

Juan Pablo Carbajal-2
Hi,

Thanks for spotting this, could you add a bug report to the tracker[0]. Thanks!

[0]: https://savannah.gnu.org/bugs/?group=octave