[Top][All Lists]

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

Re: question about contourf command

From: Pantxo Diribarne
Subject: Re: question about contourf command
Date: Mon, 17 Sep 2018 23:48:29 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Le 17/09/2018 à 19:28, Tso-Min Chou a écrit :


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'?


Sent from:

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 = "" ;  % 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));


Attachment: error_demo_2.txt
Description: Text document

reply via email to

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