필터 지우기
필터 지우기

plotting second y axis with pcolor command

조회 수: 7 (최근 30일)
Richard
Richard 2012년 4월 1일
Is it possible to prodce a pcolor plot with 2 yaxis?
Consider the following example:
clear all
temp = 1 + (20-1).*rand(365,12);
depth = 1:12;
time =1:365;
data2 = 1 + (60-1).*rand(12,1);
time2 = [28,56,84,124,150,184,210,234,265,288,312,342];
figure;
pcolor(time,depth,temp');axis ij; shading interp
hold on
plot(time2,data2,'w','linewidth',3);
Instead of plotting the second dataset on the same y axis I would like it to placed on its own y-axis, similar to the plotyy command. How can this be achieved?

채택된 답변

Aaditya Kalsi
Aaditya Kalsi 2012년 4월 1일
You can do this by creating another axis on top of the existing one in the same position. You can then play with transparencies.
Ex.:
figure;
temp = 1 + (20-1).*rand(365,12);
depth = 1:12;
time =1:365;
data2 = 1 + (60-1).*rand(12,1);
time2 = [28,56,84,124,150,184,210,234,265,288,312,342];
% create the first axis
pcolor(time, depth, temp'); axis ij;
% get axis position
axPos = get(gca, 'Position');
axLim = get(gca, 'XLim');
% Create a new axis that is transparent where data is not present
newAx = axes('Position', axPos);
plot(newAx, time2,data2,'linewidth',3);
set(newAx, 'color', 'none');
set(newAx, 'XLim', axLim)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by