Subplot line colors
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
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
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.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!