MATLAB Answers

1

Scatter3 does not update axes limits when translated

Asked by Alon Spinner on 16 Sep 2018
Latest activity Commented on by Alon Spinner on 20 Sep 2018
Hi, I am having trouble with auto-updating axes limits with scatter3 after using translation. I would like them update but they do not. invariant to "hold" and XLimMode (and the such) are on auto.
I have written a code for example below.
Thanks, Alon
%create ordinates
X=-1:0.1:1;
Y=-1:0.1:1;
Z=X.^2+Y.^2;
%scatter and obtain handle
H=scatter3(X,Y,Z);
%create translation handle
Transltn=makehgtform('translate',[100,0,0]);
Transfm=hgtransform('Matrix',Transltn);
%implement translation
H.Parent=Transfm;

  11 Comments

Well, the data are all still in the array; it's just the simulated scatter3 plot that creates the multiple line handles; there's no reason I can see why would need those for any analysis.
If one is trying to modify a given point after an analysis on the plot, then that handle is 1:1 consonant with the location in the array so the same indexing works for it as for the individual points.
"I was looking to have one handle that includes all [X,Y,Z] data..."
I've been kept stewing over the above as I didn't understand what you were driving at until just now...at least I think I do now.
If you're speaking of the data being addressable as
hS3=scattter(X,Y,X,...);
and then using
hS3.[X|Y|Z]Data
instead of just X or Y or Z, then there's not too much difference between that and writing
hL3=arrayfun(...
and using the brackets to assimilate the comma-separate list from hL3.XData as
[hL3.XData].'
it's the same array. Of course, you could make a struct from the original data as well if like the nomenclature.
I'm still left wondering why you would write it using the struct form from the figure instead of just using the original variables X,Y,Z, though?
You are in the right. What you offer will work.
to explain further, I wanted to have the ordiante data in one figure for three reasons:
  1. Plug and play - I already coded my entire program before I noticed the bug with the scatter3
  2. My code lets the user to manually play with the data, using dials and buttons, to obtain certain wanted parameters. I am unable to share it, but think of a point cloud that can be streched/compressed/rotated/translated by the user. Once the user is pleased with the parameters, he can save the cloud point into a workspace variable containing the X|Y|Z of each point and other relevant data. I have found it more efficent to update the data of the graphic object instead of deleteing it, and then creating a new one for each of the users desicisions.
  3. Child figures stack upon its parent (i.e Parent.Children=[last_child,...,first_child] in oppose to the standard way I use arrays [first_scatter3,...,last_scatter3] with A(end+1)=new_element

Sign in to comment.

Products

0 Answers