How to make LEGEND adapt when a plot is zoomed?
4 views (last 30 days)
Show older comments
I have quite a 'busy' plot with potentially up to 50 or more curves on it. I made a (large :-) legend box that allows the user to identify which curve is which.
The 'problem' is that when zooming into this figure, many of the curves become invisible. However, the number of items in the legend box does not adapt. Is it possible to show the label in the legend box only for these lines that are actually visible, or turn off labels for those lines that have become invisible because of the zooming? This would greatly enhance the clarity of the plot.
-marcel
7 Comments
dpb
on 30 Jun 2019
You might be able to adapt some of the Image Processing TB functions? (I think there are some tools there about intersection spaces altho I don't have it to know for certain.) Then there's rectint in base product that could possibly be helpful. In that case would depend greatly on the form of the data lines methinks as the bounding rectangle could enclose but there still a section being shown in part...
Walter Roberson
on 30 Jun 2019
If all x is less than plot lower x or all x is greater than plot upper x or likewise for y, then the object is off screen.
There is no built-in for this, you will need to iterate over all of the graphics objects in your zoom callback.
Be careful not to test for
all(x in range) and all(y in range)
If you do that then you incorrectly exclude objects that cross from side to side.
Answers (0)
See Also
Categories
Find more on Legend in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!