How do I create a legend that is "disconnected" from the plotted items
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Dear all, I have the following problem. I would like to plot various items that can take two colors, say red and blue. The color of each item depends on the sign of the numbers plotted.
In order to handle such a situation I would like to be able to create a legend with exactly two entries. The first one sets the red color to negative and the blue color to positive.
The reason I call it disconnected is because (1) there could be more than two items plotted, (2) a plot need not have items of both colors.
Ideally then I should be able to add a legend even before plotting.
Is this a problem that is solvable in matlab?
Thanks
1 comentario
Adam
el 15 de Mayo de 2017
You can use:
hasbehavior( hLine, 'legend', false );
to ensure that a given line is not picked up by the legend automatically.
In terms of the rest though it sounds more like you just want text on the plot rather than a legend.
Theoretically you could achieve this by using the above on all your actual plots and then just plot two objects out of the axis limits, one blue, one red that would appear on the legend as blue and red. It's not a nice solution though, there may be better ones.
Respuestas (0)
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!