我覺得我已經通讀/嘗試每一個關於此的在線建議 - 也許錯過了顯而易見的!在Matlab R2013a中,我繪製了循環中的多行(每次讀取的行數是可變的),然後添加一個圖例,其中從列表讀入系列名稱。圖例上的線條顏色與曲線上的線條顏色不匹配。Matlab的圖例顏色不正確,在一個可變大小的循環中,在圖例名稱中讀取
我試過彩色地圖,得到&設置命令,把圖例放在循環內外,爲圖例等創建一個單獨的循環...請幫助!代碼的相關部分低於:
%% getting the data....
for i=1:length(files); % for each file in the folder
FileName = files(i,1).name; % extract the filename
calfile = files(i,1).name; % lists all filenames for metadata
a = length(calfile);
fn(i,1:a) = calfile;
fid_data(i) = fopen(files(i,1).name,'r'); % open that file
data = csvread(FileName,0,1,[0 1 15 30]); %
diam(i,:) = data(9,:); % puts each channel center diameter into array
diamerr(i,:) = data(10,:); % channel centre error
end
x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30];
%% Plotting data
h = (figure('name','campaign summary','numbertitle','off'));
set(gca, 'box','on')
for r = 1:i
plot(x,diam(r,:)); % plots diameters for each flight
hold all
errorbar(diam(r,:), diamerr(r,:)); % plots error bars for each flight diameters
end
legend(fn(:,:),'location', 'northwest'); % legend derived from filename list
set(legend,'Interpreter','none'); % stops the underscore from making text subscript
你能提供一個最小的例子嗎? – bla