add image to legend label

조회 수: 25 (최근 30일)
Thales
Thales 2023년 5월 16일
답변: Image Analyst 2023년 5월 16일
Question is simple. Given a chart with two or more lines, as in:
How to add an image to the legend, instead of a label?
plot(rand(2))
legend('image1','image2')
The above creates the legend with the text labels image1 and image2. Instead of writing something, I want to identify each curve with a different figure. Is it possible?

답변 (2개)

Matt J
Matt J 2023년 5월 16일
편집: Matt J 2023년 5월 16일
The easiest way I can think of is to make several subplot axes, including one containing the line plot
subplot(1,2,1); plot(1:5);
ax=subplot(1,2,2);
Then you can manually drag and resize the empty axes and place them overtop the axes with the line plot. Then you can use the axes handles to fill the mini-axes with some image, e.g.,
imagesc(ax,imread('cameraman.tif')); axis(ax,'off')

Image Analyst
Image Analyst 2023년 5월 16일

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by