How To Modify Color of Legend Markers?
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm currently attempting to create figures from .csv files, however the resulting figures all appear to have duplicates present in the legend. I'm unsure of how to correct this issue, and have used multiple 'legend' commands to no avail. Any and all advice would be very appreciated. The code I've been using can be found below:
data_raw1=csvread('thru-plane (results) - Test48_Left_Reslice.csv',2,3);
data_raw2=csvread('thru-plane (results) - Test51_Left_Reslice.csv',2,3);
data_raw3=csvread('thru-plane (results) - Test54_Left_Reslice.csv',2,3);
% Uncomment data_raw4 read .csv file
%data_raw4=csvread('thru-plane (results) - Test56_Left_Reslice.csv',2,3);
p1=plot(data_raw1,'c');
hold on
p2=plot(data_raw2,'b');
p3=plot(data_raw3,'r');
% Uncomment to to plot
%p4=plot(data_raw4,'k');
%xlim([0 500]);
ylim([0 50]);
xlabel('Through-Thickness [\mum]');
ylabel('Oxygen Content');
hold off
legend
0 comentarios
Respuestas (1)
Walter Roberson
el 7 de Feb. de 2020
p1=plot(data_raw1,'c');
Your data_raw1 has multiple columns. plot() will produce one line for each column.
Solution:
legend([p1(1), p2(1), p3(3)], {'48_Left', '51_Left', '54_Left'})
Note: if you have enough lines in the plot then it would start using different line styles, so you might want to specify the line styles yourself, such as '-c'
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!