필터 지우기
필터 지우기

How to make a scatter plot of a 2D field in a map and add contour lines of a different field in the same map, without the contour command messing up with the color scale of the scatter command?

조회 수: 3 (최근 30일)
Say T is a vector with temperatures at specific longitudes(lon) and latitutes (lat) in a certain area.
Batim is a 2D depth field for the same area - say batim(i,j).
The command scatter(lon,lat,50,T,'filled') works fine, and shows dots with different colors (different temperatures) distributed in the domain. But if I add contour(i,j,batim,[100 1000])) or contour(i,j,batim,[100 1000]),'k'), then the T dots will be plot all with the same color.
  댓글 수: 2
Afonso Paiva
Afonso Paiva 2019년 9월 21일
The code and data files are too big to include here. The following short code gives the same results, whether you comment or uncomment the contour command:
for n=1:10; batim(n,1:5)=n*100; end
figure(1), hold on, axis([1 5 1 10])
contour(batim,'k')
t = [ 3 2 20
4 4 25
2 8 17 ];
scatter(t(:,1),t(:,2),400,t(:,3),'filled')

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

채택된 답변

darova
darova 2019년 9월 21일
Max value of batim is 1000, so MATLAB automaticaly rescale color range for [0 1000]
try
set(gca,'Clim',[0 30])

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by