Code is following
clear all; close all; clc;
% Arbitrary x's and y's
x1 = [10 20 30 40];
y1 = [1 2 3 4];
x2 = [100 200 300 400];
y2 = [105 95 85 75];
figure
plot(x1,y1,'o', 'MarkerEdgeColor', 'r', 'MarkerFaceColor', 'r')
ax2 = axes('Color','none'); % Create secondary axis
plot(ax2, x2,y2,'o', 'MarkerEdgeColor', 'b', 'MarkerFaceColor', 'b')
% Now set the secondary axis attributes
ax2.Color = 'none'; % Make the chart area transparent
ax2.XAxisLocation = 'top'; % Move the secondary x axis to the top
ax2.YAxisLocation = 'right'; % Move
i get the output
but i am looking for this output
x2 and y2 are not plotting properly.where am i going wrong?

댓글 수: 2

Guillaume
Guillaume 2017년 5월 26일
Which version of matlab?
Your code works fine for me.
Jan
Jan 2017년 5월 26일
Works fin in R2015b.

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

 채택된 답변

Steven Lord
Steven Lord 2017년 5월 26일

0 개 추천

You don't need to manually plot two axes. Use yyaxis (or for older releases that don't have yyaxis, use plotyy) instead.

추가 답변 (1개)

Kathy
Kathy 2017년 5월 26일

0 개 추천

MATLAB Version: 8.3.0.532 (R2014a)

카테고리

도움말 센터File Exchange에서 Two y-axis에 대해 자세히 알아보기

제품

태그

질문:

2017년 5월 26일

댓글:

Jan
2017년 5월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by