Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Several figures - all the same coloring for each category plotted

Asked by Dominik Wiedenhofer on 19 Sep 2013

Hello everyone,

I am currently having a problem plotting a dataset in several figures. It is always the same categories of data (7 categories x27 data points), which I am showing in several line plots and barcharts. I want the categories to always have the same colors in each figure. Strangely the line plots use a different color distribution than the barcharts, which I tried fixing by using colormap - didnt help. Changing everything by hand in the GUI seems very cumbersome, so I was hoping there might be a work-around to it automatically plots everything in the same way?

My sample code is:

myData(7x27); 
% the 7 categories by 27 data points; the categories should have the same
% coloring over all  figures created
figure % Figure 1, Barchart
hold on
bar(myData,'stacked');
coloring = get(gcf,'Colormap'); % saving the color schemes in variables
color = get(gca,'ColorOrder');
color1 = get(gca,'CLim');
v = caxis(gca);
hold off;
figure % Figure 2, line charts
hold on
plot(myData,'x--');
set(gcf,'Colormap',coloring); % trying to apply above color variables, with no effect
set(gca,'ColorOrder',color);
set(gca,CLimMode','manual','CLim',color1);

0 Comments

Dominik Wiedenhofer

Products

No products are associated with this question.

0 Answers

Contact us