pcshow permanently changes figure window?

2 visualizzazioni (ultimi 30 giorni)
John
John il 25 Nov 2022
Modificato: John il 28 Nov 2022
This is a minor issue but I'm not sure it's intended behaviour. When using pcshow to display a pointcloud, the figure window switches to a pointcloud viewer appearance (black background) and this change is persistent through clearing the figure (i.e., with clf).
Simple example:
load('object3d.mat')
figure(1);
pcshow(ptCloud);
clf; %This should leave us with a blank figure.
A = [0 0 0;0 1 0;0 0 1];
plot3(A(:,1),A(:,2),A(:,3),'.'); %plot something
This behaviour seems inconsistent with most other use cases in which clf completely resets the figure to default.

Risposte (2)

Ishan
Ishan il 28 Nov 2022
Modificato: Ishan il 28 Nov 2022
clfdeletes all children of the current figure that have visible handles.
load('object3d.mat')
figure(1);
pcshow(ptCloud);
clf; %This should leave us with a blank figure.
A = [0 0 0;0 1 0;0 0 1];
plot3(A(:,1),A(:,2),A(:,3),'.'); %plot something
So, in your case also the axes get cleared after clf is called (resulting in a black screen) and values get reset to default. When you plot on the same figure it gets plotted over the same initial set of axes you used earlier, hence the behavior seems to be consistent.
For more information, please refer to: -
Also, the recommended function to use for removing app data is actually ‘rmappdata’. ‘clf’ us mainly used to clear the figure window. The syntax for ‘rmappdata’ is as follows:
rmappdata(h,name) % removes the application-defined data, name, from its association with the UI component, h.
  1 Commento
John
John il 28 Nov 2022
Modificato: John il 28 Nov 2022
Thanks for your reply and to (Pravarthana) as well. But I still think there's a disconnect between what's happening and what users expect to happen.
I'll accept that as stated in the documentation:
clf (without any modifiers), deletes all children of the current figure that have visible handles
However, there is the extra
clf reset (different syntax) deletes all children of the specified figure and resets its properties.
Interstingly, applied to my previous example, this now gives an error.
load('object3d.mat')
figure(1);
pcshow(ptCloud);
clf reset;
Warning: Error occurred while executing the listener callback for event ObjectBeingDestroyed defined for class matlab.graphics.chart.primitive.Scatter:
Dot indexing is not supported for variables of this type.

Error in pointclouds.internal.pcui.initializePCSceneControl>cleanupPCSceneControl (line 1250)
delete(hui.UIContextMenu);

Error in clo (line 53)
obj.clo(hsave, (do_reset == 1)); % Call clo method on graphics class

Error in clf (line 117)
clo(fig, extra{:});

Error in LiveEditorEvaluationHelperEeditorId (line 4)
clf reset;

Error in connector.internal.fevalMatlab

Error in connector.internal.fevalJSON
I would maintain that based on customary understanding of the intended usage of this function, that this should not give an error.

Accedi per commentare.


Pravarthana P
Pravarthana P il 28 Nov 2022
Hi John Enright,
The functionality of ‘clf’ command is to clear the contents of the figure window.
For more information the following documentation link can be referred.
To clear the point cloud viewer from the associated UI component using "rmappdata"may be helpful.
‘rmappdata’ will remove the application data, identified by name, from its association with the UI component obj.
The following documentation links may be used for further information:
Hope this information helps you!

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by