How to make LEGEND adapt when a plot is zoomed?

6 次查看(过去 30 天)
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 个评论
dpb
dpb 2019-6-30
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
Walter Roberson 2019-6-30
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.

请先登录,再进行评论。

回答(0 个)

类别

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