Change meshgrid face color

8 ビュー (過去 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 Center および File ExchangeGraphics Object Properties についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by