How can I fix the colors of a subplot?

31 views (last 30 days)
Hello!
I have a matlab figure with a 4*2 subplot. In the first row I have 8 lines ploted and in the second 4. For the first row I have 4 lines refered to a left Y axis and 4 to the right Y axis (plotyy). I want the colors to be mantained,that is, the first line of right and left to be f.ex. red the second pink etc.
As for the second,third and forth row I have For the first row I have 2 lines refered to a left Y axis and 2 to the right Y axis. And want also the fist lines of right and left red etc.
I´ve been tryfing to set the colors with
set(gcf,'DefaultAxesColorOrder',[1 0 0;0 1 0;0 0 1;0 0 0]);
but it works only for the first row. In the second I get each line of a diferent color instead of two lines(rigt and left) of each color.
Thanks
  1 Comment
sixwwwwww
sixwwwwww on 28 Oct 2013
Your question is not completely clear. Can you please make a diagram in which you show what you need and what are you getting right now so that it could be corrected?

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 28 Oct 2013
Set it for each axes just after you call subplot() and just before you call plot():
% Apply the new default colors to the current axes.
set(gca, 'ColorOrder', newDefaultColors, 'NextPlot', 'replacechildren');
See attached color order demo below.

More Answers (0)

Categories

Find more on Two y-axis in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!