Color of legend doesnt fit the plot
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
Image Analyst
on 2 May 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 Comments
Image Analyst
on 3 May 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).
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!