필터 지우기
필터 지우기

How to remove contour line in filled contour plot?

조회 수: 56 (최근 30일)
UTKARSH VERMA
UTKARSH VERMA 2021년 8월 31일
댓글: UTKARSH VERMA 2021년 9월 1일
Hi all,
I am plotting a data using contourf but the there is a contour line between the start and end value color even after using the
contourf(x,y,z,'LineStyle','none','linecolor','none')
%or
contourf(x,y,z,'LineStyle','none')
%or
contourf(x,y,z,'linecolor','none')
For example in the attached figure there is a line between dark blue and dark red.
Also, I have tried different colormap but the result is same.

채택된 답변

DGM
DGM 2021년 8월 31일
편집: DGM 2021년 8월 31일
Hmm. I didn't think about that. I don't know that it can be done with contourf().
% make a simple linear ramp that cycles
[xx yy] = meshgrid(1:100);
zz = xx;
zz = circshift(zz,[0 -30]);
% this is what happens with contourf()
[~,h] = contourf(xx,yy,zz,9,'linecolor','none');
colormap(jet)
colorbar
% let's try to replicate it with pcolor()
clf; pcolor(xx,yy,zz);
colormap(jet(10)) % set length to number of levels+1
colorbar
shading flat
That's about right. I think it makes the colorbar easier to read anyway.
  댓글 수: 3
DGM
DGM 2021년 8월 31일
편집: DGM 2021년 8월 31일
Don't use shading interp. When you use shading interp, it will interpolate between the endpoints. It's helpful to understand that what you're looking at with pcolor() is essentially a top-down view of a surf() plot. Note how it interpolates between the maximal values and the minimal values at those boundaries. That transition is steep, but it's not perfectly vertical -- and so all those colors are visible in a narrow line.
Using shading flat doesn't do that:
and so those transition slopes don't show up:
UTKARSH VERMA
UTKARSH VERMA 2021년 9월 1일
Thanks DGM!!
It worked perfectly.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

KSSV
KSSV 2021년 8월 31일
Try:
pcolor(x,y,z) ;
colorbar ;
shading interp ;
  댓글 수: 1
UTKARSH VERMA
UTKARSH VERMA 2021년 8월 31일
Hi KSSV,
I tried your suggestion but same problem.
So, I have attached my data and here is the code I am using:
contourf(d{1},d{2},d{3}','LineStyle','none')
ylim([0 38]);
xlim([65 98]);
yticks([0:5:38]);
xticks([65:05:98]);
colormap(hsv) %or use jet
colorbar

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by