Asked by Alon Spinner
on 16 Sep 2018 at 7:46

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;

Opportunities for recent engineering grads.

Apply Today
## 11 Comments

## Walter Roberson (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_610964

You are correct. This appears to be a bug.

Furthermore if you explicitly xlim([99 101]) then it will reset ylim to [0 1] instead of [-1 1]

## Alon Spinner (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_610992

Thank you for the quick response Walter

I am trying to find an alternitive. Currently, what I use is:

where C is a vector with range [min_value,max_value].

I noticed said bug doesn't exist in plot3, but I couldn't get an equivalent plot3 to work.

Do you have an idea?

## dpb (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_611049

"said bug doesn't exist in plot3, but I couldn't get an equivalent plot3 to work."Isn't

same (altho note have to then use

as

plot3seems to turn the grid markers off)## Walter Roberson (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_611057

plot3 does not permit changing marker size individually.

## dpb (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_611101

Yeah, but OP wasn't using anything but a fixed size of the markers anywhere I see???

scatteruses an area instead of a diameter measure but it's just square of the'MarkerSize'line property.Default

'SizeData'forscatter3object is 36 and'MarkerSize'is 6 forplot3and they're indistinguishable in appearance in size.IFwere mandatory to have variably-sized markers as well, then it would be necessary to use arrayfun() or some other mechanism and build array of line handles, granted.But, the object was a workaround for the apparent bug of

scatter3wrt the translation issue.## Walter Roberson (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_611106

"currently what I use" involves a scatter3 call that uses different marker size (C) but the same color (3) for each marker. If the arguments were posted reversed and it is constant point size and varying colors per marker, then plot3 cannot deal with that either.

## dpb (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_611115

I missed seeing that comment but note what I said above:

"IF were mandatory to have variably-sized markers as well, then it would be necessary to use arrayfun() or some other mechanism and build array of line handles, granted.""... plot3 cannot deal with that"Of course it can! (albeit with some extracurricular help) :)

Treat a variable marker size vector the same way.

Granted it's not nearly as handy as

scatter3but if it has a bug, thereisa workaround if it's needed badly enough. (Again, presumingplot3doesn't have the same bug as seemed to be the case).ADDENDUMI didn't check to ensure the use of

scatter3to produce the axes didn't introduce the error; I presumed that had to do with thescatter3object inside but perhaps not. It might be safer to useplot3for that purpose as well instead; then will have to usegrid onas it seems to turn the grids off by default.## Alon Spinner (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_611432

I was looking to have one handle that includes all [X,Y,Z] data as I have to make decisions based on the entirety of the shape (for example: finding center of geometry and the such).

I suppose all those can still be made handling the array of line handles, but with much discomfort.

I have found it easier to modify the axes limits with coded conditions, to act as the 'auto' axes limits replacement.

Thanks for all the help though, dpb and Walter Roberson!

much appreciated.

## dpb (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_611497

Well, the data are all still in the array; it's just the simulated

scatter3plot 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.

## dpb (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_611855

"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

and then using

instead of just X or Y or Z, then there's not too much difference between that and writing

and using the brackets to assimilate the comma-separate list from hL3.XData as

it's the same array. Of course, you could make a

structfrom the original data as well if like the nomenclature.I'm still left wondering why you would write it using the

structform from the figure instead of just using the original variables X,Y,Z, though?## Alon Spinner (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/419214-scatter3-does-not-update-axes-limits-when-translated#comment_612401

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:

Sign in to comment.