I am holding onto a scatter plot and adding data to it through a for loop. For each data set, I would like to label it in the legend but I am running into some problems.
Show older comments
Below is the line of code I am using. As you can see I am running a for loop where each time it adds a different data set to a scatter plot (this part is working beautifully), but I can't seem to figure out how to change the display name for each data added--obviously this doesn't work and I feel like the j would be useful, but as my comment suggests, it hasn't been so far.
for j=1:height(Fe4plsr),
figure(1)
hold on
B=table2array(A4plsr(j, 2:209));
scatter(A, B, "DisplayName", "Fe")
%cant add j outside of "" to know which, cant add j inside "" because it wouldn't change
xlabel('Wavelengths(nm)')
ylabel('Frequency')
A4corr(j, :)= [B];
end
Accepted Answer
More Answers (0)
Categories
Find more on Scatter Plots 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!