Plot event listeners to update text along curve

1 view (last 30 days)
Ben Mercer
Ben Mercer on 21 Sep 2021
Hi all,
I'm attempting to create a handy function which creates a text label along a curve on a plot. E.g.
One of the challenges of this is that the Rotation property of text objects is in terms of screen coordinates, not parent axes coordinates, which means that:
A) you must transform to screen coordinates before calculating the text angle.
B) If the figure is resized or interacted with (e.g. zoom), the text angle will need to be updated.
I've tried to hack my way around the above issues using event listeners to update the angle when the axes changes size, and I've got 75% of the way there. I've attached my functions and a test script.
What I'm missing is the list of properties at the axes/figure level that I need to create listeners for. I was hoping there might be a convenient axes redraw event so I don't need to add listeners for every separate parameter that may possibly change (possibly resulting in multiple callback calls). So far I'm listening for axes.XLim, axes.YLim, axes.ZLim, axes.Position. I tried listening for figure.Position but apparently this property has a SetObservable attribute = false.
Thanks in advance :-)

Answers (0)




Community Treasure Hunt

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

Start Hunting!

Translated by