Color of legend doesnt fit the plot
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear all,
I know this question was asked thousand times before. But none of the solutions are working for me. I have a loop to import several files. Afterwards I do some calculations and want to plot them (for all the files in one plot). Therefore I use following code:
directory_name=uigetdir('','Ordner mit Messungen auswählen');
[nur_file_name,pfad]=uigetfile({'*.csv','csv-files (*.csv)';'*.*','all Files'},...
'Die csv-Files der Proben oeffnen (probe_001.csv=',[directory_name '/'], 'Multiselect', 'on');
nur_file_name=cellstr(nur_file_name);
nur_file_name=sort(nur_file_name);
filename=strcat(pfad,nur_file_name);
anzahl_files=size(filename,2);
for xy=1:anzahl_files
fid_in=fopen(char(filename(xy)),'r');
%Calculations...
%Plot Sr ratio for all files:
[NumRows1 NumCols1]=size(Ratio);
figure(1)
title('Proben 87Sr/86Sr');
xlabel('Partikel');
ylabel('87Sr/86Sr');
for p=1:anzahl_files
h(p)= scatter(1:NumRows1, Ratio(:,1));
legendtext{p} = filename_s(1,p);
hold on
end
legend(h, legendtext)
end
I am sorry to ask this again. But I dont find my mistake. It plots perfectly, the probleme is just that the colours are not matching. I appreciate any help.
0 Kommentare
Antworten (1)
Image Analyst
am 2 Mai 2022
Why are you plotting the same data (the first column of Ratio) every iteration? If you do that, all the markers are on top of each other so that only the last set will show up. Did you mean to scatter different columns of Ratio like this:
h(p)= scatter(1:NumRows1, Ratio(:, p));
9 Kommentare
Image Analyst
am 3 Mai 2022
Your indenting is all messed up. Looks like you have a for loop with 5 other for loops inside of it. Is that what you want?
Type control-a (to select all) then control-i (to fix the indenting).
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!