How can I add a second Y axis with a different scale in a plot in MATLAB 7.9 (R2009b)?

조회 수: 15 (최근 30일)
I create a plot and want to have two different Y scales to display two different units for the same data. For example, when I draw the following plot:
figure;
plot(1:10);
I want to add the second Y axis with the following limits:
[20 25]

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 12월 24일
The following examples show how to add the second Y axis that ranges from 20 to 25:
1. Add the second Y axis manually:
% Plot function.
h = plot(1:10)
hold on
box off
% Create second Y axes on the right.
a2 = axes('YAxisLocation', 'Right')
% Hide second plot.
set(a2, 'color', 'none')
set(a2, 'XTick', [])
% Set scala for second Y.
set(a2, 'YLim', [20 25])
2. Use PLOTYY:
figure;
[a,h1,h2]=plotyy(1:10, 1:10, 1:10, linspace(20,25,10));
delete(h2);
set(a(2),'ycolor', get(a(1), 'ycolor'));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

제품

Community Treasure Hunt

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

Start Hunting!

Translated by