Only last plot visible in for loop, different colors between bar and line plot

3 次查看(过去 30 天)
Hi,
I'm having two issues. I have an image that is a bar graph and I'm trying to overlay line plots over it in a for loop. I have two issues. 1) I have three bars (variables) for each day (time on x-axis) and i have three time series lines that I'm trying to make the same color. Each variable (line and bar) being the same color. Any ideas?
2) In an attempt to do this, I created a for loop hoping that I could make each line plot match the color of its respective bar color. However when I do this, only the last line plot shows up.
If I can resolve #1 without a for loop then I don't need #2. Thanks guys!
bar(argentina(:,1:10,4).'); %,colorr(j));
set(gca,'XTick',1:10,'XTickLabel',datstmp(1:10),'YTick',0:5:pcpY);
title('Argentina Regional Mean Daily Precip','FontSize',16,'FontWeight','bold')
ylim([0 pcpY])
ylabel('Daily Totals (mm)')
legend(ARGregions, 'Location','Northwest')
xlim([0 11])
hAxes = gca;
hAxes_pos = get(gca,'Position');
hAxes2 = axes('Position',hAxes_pos);
plot(ApcpCum(j,1:10).','Marker','*','LineWidth',2,'color',color(j,:))
hold on
set(hAxes2,'YAxisLocation','right','Color','none','XTickLabel',[])
ylim([0 150]);
h1_xlim = get(hAxes,'XLim'); % store x-axis limits of first axes
set(hAxes2,'XLim',h1_xlim) % specify x-axis limits of second axes
% code
  1 个评论
dpb
dpb 2014-2-21
编辑:dpb 2014-2-21
Why can't you simply set the line() color on the plot to match that of the respective bar desired in 1)?
ADDENDUM: As a general principle it would be much simpler to debug an issue if you could make a trivial demo (using random data is good for this purpose) that demonstrates the problem specifically instead of folks either having to build a demo from scratch or try to make yours work w/o any data.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by