필터 지우기
필터 지우기

Subplot line colors

조회 수: 6 (최근 30일)
Aadil
Aadil 2012년 4월 24일
How do you automatically change the colours of lines in subplots?
Its too much hassle manually setting the colours
I tried the colororder method: set(gca,'ColorOrder',jet(8), didn't work.
Thanks
%%1.
i = 1;
figure(i)
set(gcf,'DefaultAxesPosition', [0.130 0.090 0.775 0.850],'defaulttextinterpreter','none','Visible','off','PaperOrientation', 'portrait','PaperPositionMode','manual','PaperPosition',[0.15, 0, 20, 30])
set(gca,'ColorOrder',jet(8),'fontsize',10);
subplot(2,1,1)
hold all
%Set Parameters to Plot
if exist('V_SCD_CE_ct_NormEff_Count'); plot(Elapsed_Time, V_SCD_CE_ct_NormEff_Count,'LineWidth', 1); else plot(0,NaN,'w'); end;
h=legend('V_SCD_CE_ct_NormEff_Count');
set(h,'fontsize',6, 'Interpreter', 'none');
%Set Labels for X and Y Axes'
ylabel ('V_SCD_CE_ct_NormEff_Count');
h_ylabel = get(gca,'ylabel');
set(h_ylabel,'FontSize',7);
%Set Limit Conditions and Ticks
xlim([-inf inf]);
grid on;
box on;
hold off
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(2,1,2)
hold all
%Set Parameters to Plot
if exist('P_SCD_CE_NormEff_EWMA_Filt_Val'); plot(Elapsed_Time, P_SCD_CE_NormEff_EWMA_Filt_Val,'LineWidth', 1); else plot(0,NaN,'w'); end;
h=legend('P_SCD_CE_NormEff_EWMA_Filt_Val');
set(h,'fontsize',6, 'Interpreter', 'none');
%Set Labels for X and Y Axes'
ylabel ('V_SCD_bs_CE_Scrn_Cond');
h_ylabel = get(gca,'ylabel');
set(h_ylabel,'FontSize',7);
%Set Limit Conditions and Ticks
xlim([-inf inf]);
grid on;
box on;
hold off
  댓글 수: 2
Aadil
Aadil 2012년 4월 25일
anyone?
Jan
Jan 2012년 4월 25일
Your question is not easy to answer. 1. "didn't work" is always a problem: Solving a problem is much easier than guessing what the problem is.
2. "Automatically change the colors of lines" is not unique. What does this exactly mean?
3. "It's too much hassle to set the colors manually"? Is it? You need some lines of Matlab code only. If it is a hassle for you, you are talking about an unknown approach, but did not explain this.
4. The posted program contains a lot of not relevant code. Does it solve your problem, but "with too much hassle"? Or should the wanted code be inserted in your code?
I suggest to improve the question by editing it: Tell exactly what lines should be set to which colors, post the relevant code only, show what you have tried already and which problems occurred. Then an anwer will be easier and not a wild guessing.

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

답변 (1개)

Daniel Shub
Daniel Shub 2012년 4월 25일
You cannot do it easily:
<http://www.mathworks.co.uk/support/solutions/en/data/1-15TTM/index.html?solution=1-15TTM >
<http://blogs.mathworks.com/loren/2007/12/19/plotting-with-style/ >
Also I don't think your code does what you want it to do.
set(gca,'ColorOrder',jet(8),'fontsize',10);
subplot(2,1,1)
sets the colororder of the current axis, and then promptly changes the current axis in such a way that the axis in which you set the colororder get deleted.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by