How can I delet a point in Uiaxes thats Handlevisibility is set to 'off''

I designed an App with the App designer with several UIAxes.
When the user selects one or more samples, they are plotted and displayed in a legend.
Now I would like to show the maximum values. If I put crosses on the maximums, I don't want them to appear in the legend.
Therefor I set the HandleVisibility on 'off'.
My problem now is that when I select other samples and the graph is replotted, the old crosses at the positions of the previously selected samples are still visible.
How can I change this?
cla() and setting the HandleVisibility to 'on' is'nt working.

 Respuesta aceptada

Adam Danz
Adam Danz el 19 de Ag. de 2020
Control what appears in the legend without setting HandleVisibility to off.
Use object handles to specify what belongs in the legend or turn the the legend's AutoUpdate property off to prevent additional objects from appearing within the legend.
Both methods are demonstrated in my answer in another question.

4 comentarios

The problem is that the number of elements in the legend keeps changing.
In addition, data sets are plotted in a loop. Therefore the command of the legend is also in the loop. I can't tell if it's just one graph or maybe twenty.
Is there any way to set the 'AutoUpdate' to 'off' without knowing the number of legend entries? Maybe after the loop?
The legend command should not be within the loop. That slows down the code.
Instead, collect the graphics object handles within the loop and then use those handles to specify the legend after the loop.
Here are two examples; notice that the legend strings are assigned using DisplayName rather than listing them within the legend function.
Alternatively, you can use legendUnq() from the file exchange, written specifically for loops. The idea is to assign a legend string for each object that should appear in the legend in the object's DisplayName property. Objects that should not appear in the legend should have an empty DisplayName (which is the default). After the loop, simply call,
legend(legendUnq())
and the legend should be populated with objects that have a non-empty DisplayName. Here's an example.
The 2-step approach with 'DisplayName' works - thanks a lot!!
Glad I could help!

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by