How to add a cylinder to a scattered plot
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Chunru
2021-11-26
% 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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!