Legend doesn't match my plot style
    8 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    MOHAMED Camara
 il 3 Dic 2019
  
    
    
    
    
    Commentato: Image Analyst
      
      
 il 3 Dic 2019
            I'm trying to match the legend with plot style, but it only shows the legend wrong.The problem is I have 3 different plot styles and different colors but the legend doesn't match with plot.
Here is my code:
figure;
hold all;
plot(max_time1,R1M1V1,'bs');
plot(max_time2,R2M1V1,'-.r');
plot(max_time3,R3M1V1,'--m');
title('Impedance Vs Time');
legend({'R1M1V1','R2M1V1','R3M1V1'});
hold off;
The output is below.

What am I doing wrong?
Thanks in advance
0 Commenti
Risposta accettata
  Image Analyst
      
      
 il 3 Dic 2019
        
      Modificato: Image Analyst
      
      
 il 3 Dic 2019
  
      Are they vectors or matrices?  Can you attach your data?
Anyway, put hold on after the first call to plot.  That's the way I always do it, ,though hold all before might work
plot(max_time1,R1M1V1,'bs');
hold on;
plot(max_time2,R2M1V1,'-.r');
plot(max_time3,R3M1V1,'--m');
2 Commenti
  Image Analyst
      
      
 il 3 Dic 2019
				Error using xlsread (line 136)
XLSREAD unable to open file 'V-CAMARA_M2'.
File 'V-CAMARA_M2' not found.
Error in test5 (line 15)
voltage1_data=29671.2*xlsread(filename,sheet,voltage1); 
Still can't reproduce.  Can you attach the workbook?
Più risposte (1)
  Hank
      
 il 3 Dic 2019
        It looks like R1M1V1 is plotting three different curves. This could happen if max_time1 is a vector but R1M1V1 is a Nx3 matrix.
Plot will interpret each of the columns as a separate curve. Then, when you say legend('R1','R2','R3'), only the first three curves are labeled.
If all the data in R1M1V1 is the same type, they can be plotted in a single curve  
 plot(max_time, R1M1V1(:),'sb'); % use the 'vector(:)' syntax to force all the data into a column vector
 % % do this for all the plots
Vedere anche
Categorie
				Scopri di più su Legend 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!