Hi,
I have two m scripts with the same code for plotting. How can I plot results from the two scripts at the same plot?
figure1 = figure('Color',[0 1 1]);
axes1 = axes('Parent',figure1,'FontSize',12,'FontName','arial');
plot1 = plot(X,Y,'Parent',axes1,'MarkerSize',3);
hold all;
set(plot1(1),'MarkerFaceColor',[1 0 1],'Color',[1 0 1]);
Thank you

 채택된 답변

lvn
lvn 2014년 6월 27일
편집: lvn 2014년 6월 27일

0 개 추천

The problem are these lines:
figure1 = figure('Color',[0 1 1]);
axes1 = axes('Parent',figure1,'FontSize',12,'FontName','arial');
which creates a new figure. Simply remove it in the last 2 m-files and it should work.

댓글 수: 1

Anya
Anya 2014년 6월 27일
I tried with figure('Color',[0 1 1]); in last 2 m-files but still the same , I have different figures, code:
figure('Color',[0 1 1]);
axes1 = axes('Parent',figure,'FontSize',12,'FontName','arial');
plot1 = plot(X,Y,'Parent',axes1,'MarkerSize',3);
hold all;
set(plot1(1),'MarkerFaceColor',[1 0 1],'Color',[1 0 1]);

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

추가 답변 (1개)

Mischa Kim
Mischa Kim 2014년 6월 27일

1 개 추천

Anya, how about adding a
hold all
after the first plot command?

댓글 수: 6

Anya
Anya 2014년 6월 27일
I tried but still I have three plots on three different figures
Mischa Kim
Mischa Kim 2014년 6월 27일
OK. Could you post all the code for the four command lines you posted? Debugging is a challenge without.
Anya
Anya 2014년 6월 27일
I changed code in my question, code is the same for all three m files, I wanted now to plot results from them at the same figure
Mischa Kim
Mischa Kim 2014년 6월 27일
편집: Mischa Kim 2014년 6월 27일
This should do:
% first script
X = 1:10;
Y = sin(X);
figure1 = figure('Color',[0 1 1]);
axes1 = axes('Parent',figure1,'FontSize',12,'FontName','arial');
plot1 = plot(X,Y,'Parent',axes1,'MarkerSize',3);
set(plot1(1),'MarkerFaceColor',[1 0 1],'Color',[1 0 1]);
hold all;
...
% second script
X = 1:10;
Y = cos(X);
plot1 = plot(X,Y,'MarkerSize',3);
set(plot1(1),'MarkerFaceColor',[1 0 1],'Color',[1 0 1]);
...
You probably want to change the settings in the second set command, though.
Anya
Anya 2014년 6월 27일
This is working but you deleted axis and figure definition which I want to use in the second script
Anya
Anya 2014년 6월 27일
I put parametars that I needed from the figure and axis into plot and got the same. Thank you it is working now

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

카테고리

도움말 센터File Exchange에서 Line Plots에 대해 자세히 알아보기

태그

질문:

2014년 6월 27일

댓글:

2014년 6월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by