Home Matlab Creating a legend that is unrelated to the plotted data

Creating a legend that is unrelated to the plotted data

by Janis
Creating a legend that is unrelated to the plotted data

I am currently developing a code that identifies two types of objects in an image. The goal is to compare the locations of the second type of object (smaller objects) with the border of the first type (larger objects). To visualize this, I created a figure where the original image is displayed, the borders of the large objects are drawn, and the small objects are highlighted in a different color. I’ve color-coded the small objects based on their positions: color 1 for those inside a larger object, color 2 for those on the perimeter of a larger object, and color 3 for those outside. Additionally, I’ve plotted lines from each small object to the larger objects, with each line corresponding to one of the three colors.

Now, I would like to add a legend that simply explains the color coding: “color 1 = inside, color 2 = perimeter, color 3 = outside”. However, when I attempt to add a legend, it generates separate entries for each individual line in the plot. Is there a way to create a legend that describes the meaning of each color without linking it to every individual line in the plot?

Related Posts

Leave a Comment