nanContourf(xb,yb,x​,y,z)

버전 1.4.0.2 (2.92 KB) 작성자: Benoit Pasquier
contourf with nans filled in precisely
다운로드 수: 398
업데이트 날짜: 2021/7/8

nanContourf

Like contourf but fills in the nans nicely given grid borders.

View nanContourf on File Exchange

Example

Code:

% start from peaks, cropped for asymmetry
z = peaks ;
z(end,:) = [] ;

% some coordinate system 
x = sin(linspace(-1,1,size(z,2))) ;
y = log(linspace(1,3,size(z,1))) ;

% create some nan islands and lakes
iznan = find(flipud(sin(z))>.5) ;
z(iznan) = nan ;

% usual contourf
subplot(2,1,1)
contourf(x,y,z)
title('usual contourf')

% nanContourf (needs border coordinates)
% so I create some around x and y 
subplot(2,1,2)
xb = (x(2:end)+x(1:end-1))/2 ;
xb = [2*x(1)-xb(1) xb 2*x(end)-xb(end)] ;
yb = (y(2:end)+y(1:end-1))/2 ;
yb = [2*y(1)-yb(1) yb 2*y(end)-yb(end)] ;
nanContourf(xb,yb,x,y,z)
title('nanContourf')

AWESOME OCIM example:

figure(1)
TRACER = (cosd(ao.LAT) + sind(ao.LON) + cosd(ao.DEPTH / 100)) ;
TRACER(find(~ao.OCN)) = nan ;
TRACER_Slice = squeeze(TRACER(:,100,:)) ;
contourf(ao.lat, ao.depth, TRACER_Slice')
set(gca,'YDir','reverse')


figure(2)
z = ao.depth ;
zb = [0 cumsum(ao.height)] ;
y = ao.lat ;
dy = y(2) - y(1) ;
yb = [y(1) - dy/2    y + dy/2] ;
nanContourf(yb, zb, y, z, TRACER_Slice') ;
set(gca, 'YDir', 'reverse')

인용 양식

Benoit Pasquier (2024). nanContourf(xb,yb,x,y,z) (https://github.com/briochemc/nanContourf/releases/tag/v1.4.0.2), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2012a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.4.0.2

See release notes for this release on GitHub: https://github.com/briochemc/nanContourf/releases/tag/v1.4.0.2

1.4.0.1

See release notes for this release on GitHub: https://github.com/briochemc/nanContourf/releases/tag/v1.4.0.1

1.4.0.0

See release notes for this release on GitHub: https://github.com/briochemc/nanContourf/releases/tag/v1.4.0.0

1.3.2.0

cleaned description of function and code

1.3.1.0

commented and simplified code a bit

1.3.0.0

changed a lot. Now fills the nan boxes individually. This enables to deal with 'lakes' but creates a problem when printing to eps.

1.1.0.0

Added an extrapolation (inpaint_nans) to get rid of the white borders of nans.
just got rid of the v2 in the top right sublot

1.0.0.0

added the fact it does not work for 'lakes'

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.