Only last plot visible in for loop, different colors between bar and line plot
    4 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
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 Commento
  dpb
      
      
 il 21 Feb 2014
				
      Modificato: dpb
      
      
 il 21 Feb 2014
  
			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.
Risposte (0)
Vedere anche
Categorie
				Scopri di più su Graphics Performance in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

