Using markers for data, lines for simulations
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to plot curves associated with many simulations, hold the figure, then plot the data, but all with markers instead of lines. I can set them all by hand, and then generate the code, but this makes me set each line by hand in my m-file. See my bit of code that is unfinished...
sim = c2pyr(x,time,flip);
H1=plot(time,sim)
set(H1,'LineWidth',2,'LineStyle','--');
hold on
H2=plot(time,data);
set(H2,'LineStyle','none',' (I want to make everything markers)
hold off
댓글 수: 0
채택된 답변
sunil anandatheertha
2012년 1월 19일
hmm, please see if this is of some help to you (though this one does not use function handles!!):
>> a=1:10;b=a.^2;c=a.^3; plot(a,b,'k','LineStyle','--','LineWidth',3),hold on,plot(a,c,'ks','MarkerFaceColor',[1 0 0],'MarkerEdgeColor',[0 1 1]),hold off
추가 답변 (1개)
Venn Ravichandran
2012년 1월 19일
You have several sets of "sim" and "data" variable and you want to plot lines for sim and markers for data, right? There are at least 2 solutions, I think you are looking for the second one...
First solution...
for i = 1:numSimulations
[time, sim, data] = ... % simulate and get the data
plot(time, sim, 'linestyle', '--', 'linewidth',2,...
time, data, 'linestyle', 'none', 'marker', '.');
hold all; % using all to allow cycling through colors
end
Second solution... You can get all the lines that have been plotted on the current axis and then set the linestyles and markers for all of them.
h = findobj(gca,'Type','line'); % get all lines
set(h, 'Linestyle', '--', 'Linewidth', 2); % set their line styles
% Hint: if you want the "sim" plots to have lines and "data" plots to have markers, you could look at the odd/even indices to h
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!