Error using yyaxis axes!! Argument type?

조회 수: 5 (최근 30일)
noMathWiz
noMathWiz 2020년 10월 13일
답변: noMathWiz 2020년 10월 13일
Folks,
I'm receiving the below yyaxis plotting error in one section of my code. The code works normally when I copy it to a new .mlx. I receive the error when I run the section alone within the larger program, and I also receive the error when I run the whole program. Separately, when copied into a new .mlx file, the code works exactly as is.
Notes:
1) The code was working earlier with no known changes
2) Other parts of my code in other sections use the same formatting and they work
fig42 = figure(42);
left_color = [0 0 1];
right_color = [1 0 0];
set(fig42,'defaultAxesColorOrder',[left_color; right_color]);
yyaxis right
plot(t,a,'--r','LineWidth',.5)
hold on
yyaxis left;
plot(t2,a2,'b','LineWidth',2.5)
title({'Test plot',...
Error using yyaxis
Axes argument must be a Cartesian Axes of type matlab.graphics.axis.Axes

채택된 답변

noMathWiz
noMathWiz 2020년 10월 13일
The cause of the error is figure(42) is referenced earlier in the program, so MATLAB is confused. Reassigning the figure to a different number cleared the error.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by