Change meshgrid face color
23 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
SuzieChan
el 22 de Abr. de 2020
Comentada: Ayush singhal
el 28 de Abr. de 2021
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)')
0 comentarios
Respuesta aceptada
Sindar
el 22 de Abr. de 2020
surf(Ltm, Lnm, Pm,'FaceAlpha',0.5)
to set transparency to 50%. See other options here
5 comentarios
Sindar
el 28 de Abr. de 2021
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
el 28 de Abr. de 2021
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;
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!