Change meshgrid face color

조회 수: 7 (최근 30일)
SuzieChan
SuzieChan 2020년 4월 22일
댓글: Ayush singhal 2021년 4월 28일
Hi.
What code do I need to change meshgrid face color to 'transparent'?
Thank you.
N = 100; % Size Of Interpolation Vectors/Matrices
Ltv = linspace(min(W(:,1)), max(W(:,1)), N); % Latitude Vector For Interpolation
Lnv = linspace(min(W(:,2)), max(W(:,2)), N); % Longitude Vector For Interpolation
[Ltm,Lnm] = meshgrid(Ltv, Lnv); % Matrices For Interpolation
Pm = griddata(W(:,1), W(:,2), W(:,3), Ltm, Lnm); % Interpolate
figure
surf(Ltm, Lnm, Pm)
colorbar;
grid on
view(40,40)
xlabel('Latitude')
ylabel('Longitude')
zlabel('Total Precipitation (mm)')

채택된 답변

Sindar
Sindar 2020년 4월 22일
surf(Ltm, Lnm, Pm,'FaceAlpha',0.5)
to set transparency to 50%. See other options here
  댓글 수: 5
Sindar
Sindar 2021년 4월 28일
Use axis equal:
[x, y] = meshgrid(-10:2:12); % Generate x and y data
z = zeros(size(x,2)); % Generate z data
surf(x, y,z,'FaceAlpha' , 0.1) % Plot the surface
view(2)
axis on
%
hold on
L_x = 10;
L_y = 10;
L_z = 6;
vert = [0 0 0;L_x 0 0;L_x L_y 0;0 L_y 0;0 0 L_z;L_x 0 L_z;L_x L_y L_z;0 L_y L_z];
fac = [1 2 6 5;2 3 7 6;3 4 8 7;4 1 5 8;1 2 3 4;5 6 7 8];
patch('Vertices',vert,'Faces',fac,...
'FaceVertexCData',hsv(6),'FaceColor','flat', ...
'FaceAlpha', 0);
view(3)
axis vis3d equal
% rotate3d
xlabel('x')
ylabel('y')
zlabel('z')
xlim([-10 10])
ylim([-10 10])
zlim([-1 10])
Ayush singhal
Ayush singhal 2021년 4월 28일
Thanks a lot. It works perfect.
[x, y] = meshgrid (-10: 1: 12); % Generate x and y data
z = zeros (size (x, 2)); % Generate z data
surf (x, y, z, 'FaceAlpha' , 0.1) % Plot the surface
view (2)
axis on
%
hold on
L_x = 4;
L_y = 4;
L_z = 4;
vert = [0 0 0; L_x 0 0; L_x L_y 0; 0 L_y 0; 0 0 L_z; L_x 0 L_z; L_x L_y L_z; 0 L_y L_z];
fac = [1 2 6 5; 2 3 7 6; 3 4 8 7; 4 1 5 8; 1 2 3 4; 5 6 7 8];
patch ( 'Vertices' , vert, 'Faces' , fac, ...
'FaceVertexCData' , hsv (6), 'FaceColor' , 'flat' , ...
'FaceAlpha' , 0.3);
view (3)
axis vis3d equal
% rotate3d
xlabel ( 'x' )
ylabel ( 'y' )
zlabel ( 'z' )
xlim ([-4 8])
ylim ([-4 8])
zlim ([- 1 10])
########
Now thw below code generates stripe pattern. Major problem is that to put those stripes onto the above code image( where cube is on the image plane). I want something like that is shown in screenshot.
If I am adding this code in the above mentioned code then meshgrid is going to disapper.
screenSize = get(0, 'MonitorPositions')
screenWidth = screenSize(3)
screenHeight = screenSize(4)
stripeWidth = 50; % Pixels
oneCycle = repelem([0,1], stripeWidth);
% Make vertical stripes.
numStripes = floor(screenWidth / (2* stripeWidth))
multipleCycles = uint8(255 * repmat(oneCycle, [screenSize(4), numStripes]));
cmap = [1 1 1; 0 0 0];
S= imrotate(multipleCycles,-45)
imshow(S, [], 'ColorMap', cmap);
axis on;

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by