legend in 2d line plot
古いコメントを表示
I'm plotting data in a for loop where I'm looping through two datasets so using plot...; hold on;plot...
I only want the legend for the first plot, but there doesn't seem to be a way of doing this. Any advice?
Failing this, is there a way of adding a graph onto a currently existing graph. So, that I could just plot the first with a legend and then plot the second on top of this without a legend?
The code I've written is shown below:
for i = 1:length(LakeName);
for ii = 1:length(CorrVariables)
fh{ii} = figure(ii);
plot(HiResDay,HiRes.(LakeName{i}).(CorrVariables{ii}),'linewidth',2,'color',cmap(i,:));hold on;
plot(LowResDay,LowRes.(LakeName{i}).(CorrVariables{ii}),'--k','linewidth',3);
hTitle = title ([CorrVariables{ii} ' 2011']);
hXLabel = xlabel('Time (Day of year)' );
hLegend = legend(LakeName{:});
end
end
This doesn't work as I expected; the legend shows the line for the first plot and then the second, then back to the first, so in the end I have the first legend entry in the designated color, then the second legend entry shown according to '--k'.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!