Why do plotting commands delete axes UserData?

2 visualizaciones (últimos 30 días)
Bruce Elliott
Bruce Elliott el 16 de Abr. de 2020
Comentada: Steven Lord el 16 de Abr. de 2020
If I store data in the UserData property of an open axes object and then plot something on the axes, the UserData is deleted. Does this happen for a good reason, and is there any way to prevent it?
Here is sample code to illustrate this:
>> myAx = axes;
>> myAx.UserData = 1:10;
>> myAx.UserData
ans =
1 2 3 4 5 6 7 8 9 10
>> plot(rand(5))
>> myAx.UserData
ans =
[]
I'd like to have UserData persist after adding more graphics objects to the axes.

Respuesta aceptada

Bruce Elliott
Bruce Elliott el 16 de Abr. de 2020
This was a silly question - I just need to call
>> hold on
before plotting. I knew that about graphics objects, but hadn't realized that all the axes properties are replaced by new plot commands.
  1 comentario
Steven Lord
Steven Lord el 16 de Abr. de 2020
Not all properties are reset. Units and Position keep their values.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Programming en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by