フィルターのクリア

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

3 ビュー (過去 30 日間)
Ryan
Ryan 2014 年 2 月 21 日
編集済み: dpb 2014 年 2 月 21 日
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 Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by