Alternative to scatter3 plot

12 vues (au cours des 30 derniers jours)
John Deer
John Deer le 19 Août 2022
Réponse apportée : Gautam le 30 Sep 2024
i often need to display X,Y,Z Data which are colored.
So far, i use
figure;
scatter3 (X,Y,Z, DotSize ,Z) ;
which delivers the desired result and is a single line of code (easy to remeber and usable on many different computers without implementing own stuff every time)
But the resulting graphs are very (and sometimes extremely) slow in reaction.
Even closing the graph is very slow.
A more potent graphic card does not have the slightest effect on that.
Is there another way to display X,Y,Z data colored and more efficient ?
Of course, i can use plot3, but then the data are not colored.
thx
  2 commentaires
Mike Croucher
Mike Croucher le 19 Août 2022
Which version of MATLAB are you using? How big is the data?
John Deer
John Deer le 22 Août 2022
Modifié(e) : John Deer le 22 Août 2022
This behaviour ocurrs in all Versions that i've used so far, as they where Version 2017 to 2021.
The data have differenz size. The maximum possible size is 2048x2048, but usually the data is much less in size.
Below, there is an example.
The Data consists of several patches, and they are combined in a loop like
figure;
hold on;
for i = 1:maxSize
scatter3(X{i},Y{i},Z{i}, dotSize, Z{i})
text(...)
end

Connectez-vous pour commenter.

Réponses (1)

Gautam
Gautam le 30 Sep 2024
I am assuming the data you have, i.e. X, Y and Z are vectors. In this case, you can use the “scatter3” function without the loop. This will highly increase your performance.
scatter3(x(:),y(:),z(:),[],z(:),"filled");
set(gca,"View",[0 90])
This gives the output
Also, if you want a flat plot as you have mentioned in the comments, you can use the “scatter” function instead of “scatter3” and pass in the “Z” values for color or consider using the “imagesc” function.
These would give you the same output as in the above image
You refer to the following MathWorks documentation for more information:

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by