How to add a cylinder to a scattered plot
1 view (last 30 days)
Show older comments
Hello everyone,
I currently have a 3D data plot which I will like to superimpose with a cylinder.
Here is my current code:
%clear all;
%close all;
clc
A = load ('Data.txt');
x = A (:,1 ) ;
y = A (:,2 ) ;
z = A (:,3 ) ;
Amplitude = A (:,4) ;
scatter3 (x , y, z, 30, Amplitude )
title ('Cylinderical Sample')
xlim ([-0.07 0.07])
ylim ([-0.09 0.09])
zlim ([0 0.10])
xlabel ('Breath /m')
ylabel ('Width /m')
zlabel ('Height /m')
pbaspect([1 1 2])
H = colorbar ;
ylabel (H, 'Amplitude')
And results:
My challenge is that should i try to include a cylinder, I lose seeing the points in my scattered plot.
Here is the code I prepared to include the cylinder:
%clear all;
%close all;
clc
A = load ('Data.txt');
x = A (:,1 ) ;
y = A (:,2 ) ;
z = A (:,3 ) ;
Amplitude = A (:,4) ;
r = 0.025;
scatter3 (x , y, z, 30, Amplitude);
[X,Y,Z] = cylinder(r);
surf (X,Y,Z);
title ('Sample - VS 126')
xlim ([-0.07 0.07])
ylim ([-0.09 0.09])
zlim ([0 0.10])
xlabel ('Breath /m')
ylabel ('Width /m')
zlabel ('Height /m')
pbaspect([1 1 2])
H = colorbar ;
ylabel (H, 'Amplitude')
And here is how I have the results now:
Top View of Results:
Is it possible that I can get some assistance with including the cylinder into the scattered plot?
Thank you.
--
Greek
0 Comments
Accepted Answer
Chunru
on 26 Nov 2021
% A = load ('Data.txt');
A = 0.05*rand(8, 4)
x = A (:,1 ) ;
y = A (:,2 ) ;
z = A (:,3 ) ;
Amplitude = A (:,4) ;
scatter3 (x , y, z, 30, Amplitude )
title ('Cylinderical Sample')
xlim ([-0.07 0.07])
ylim ([-0.09 0.09])
zlim ([0 0.10])
xlabel ('Breath /m')
ylabel ('Width /m')
zlabel ('Height /m')
pbaspect([1 1 2])
H = colorbar ;
ylabel (H, 'Amplitude')
hold on
r = 0.025;
[X,Y,Z] = cylinder(r);
surf (X,Y,Z, 'EdgeColor', 'none', 'FaceAlpha', 0.2);
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!