Command 'plot3' clears functions which were added when an axes is created in GUIDE. Why?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Alon Rozen
el 24 de En. de 2017
Comentada: Alon Rozen
el 24 de En. de 2017
Hi all,
I created an axes - My_Axes (using GUIDE but I think it doesn't matter) - and specified a 'ButtonDownFcn' to treat mouse clicks on the created graph. However, when I plot something on this axes using the the funcition 'plot3' the axes field 'ButtonDownFcn' is cleared! Of course, nothing happens when later I click with the mouse on the graph. Strangely, this is not the case when I create a graph using 'plot' (I didn't check all the other plotting functions). Why? Is this the way Matlab is suppose to treat axes?
Thanks,
Alon
0 comentarios
Respuesta aceptada
Steven Lord
el 24 de En. de 2017
I don't believe this is a bug. When you call a high-level plotting function like plot or plot3, MATLAB needs to know how to configure the axes into which the graphics object will be plotted. By default, "new plots added to the axes clear existing plots and reset all axes properties." [That's not technically true; the Position and Units properties keep their values.]
To avoid this behavior, use the hold function to change the behavior from the default behavior I described above, use a lower-level plotting function like line, or manually change the axes NextPlot property (which is similar or equivalent to what hold does.)
I'm guessing you didn't see this behavior when you called plot because you also used hold or because you set the ButtonDownFcn property after plotting.
Más respuestas (1)
Ver también
Categorías
Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!