Patch

8 ビュー (過去 30 日間)
zhiping
zhiping 2011 年 6 月 8 日
コメント済み: Meg Noah 2025 年 8 月 5 日
hi, I use the command 'patch' to create one or more strip. And I realise this function, but for now I want to add the information associated in the center of each polygon, how can I do? I found nothing similar. Thanks in advance.
Here is the code %%%%%%
figure y=[0 0 1 1;1 1 2 2]'; x=[0 10 10 0;0 10 10 0]'; c=[20 30]'; set(gca,'CLim',[0 40]); p=patch(x,y,''); set(p,'FaceColor','flat','FaceVertexCData',c,'CDataMapping','scaled'); %%%

回答 (1 件)

Sean de Wolski
Sean de Wolski 2011 年 6 月 8 日
So you want to be able to see a smaller polygon inside a bigger one?
Use the facealpha and edgealpha properties to make the larger patch object more translucent and the inside one less translucent.
%Rendering overlay example
I1 = false(100,100,100); %First image
I1(10:90,10:90,30:70) = true; %make rectangular part of I true
[xx yy zz] = meshgrid(1:100,1:100,1:100); %second image sphere with radius 10 centered at (50,50,50)
I2 = sqrt((xx-50).^2+(yy-50).^2+(zz-50).^2)<10;
fv1 = isosurface(I1,0); %Make the triangles
fv2 = isosurface(I2,0);
%Blue ball inside light green box
figure; hold on
patch(fv1,'facecolor',[0 1 0],'facealpha',0.3,'edgecolor','none');%[.5 .5 0],'edgealpha',0.3);
patch(fv2,'facecolor',[0 0 1],'facealpha',0.7,'edgecolor','none');
view(19,28)
  2 件のコメント
zhiping
zhiping 2011 年 6 月 8 日
no, excuse me, I gave few details, there are a part of code
%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure
y=[0 0 1 1;1 1 2 2]';
x=[0 10 10 0;0 10 10 0]';
c=[20 30]';
set(gca,'CLim',[0 40]);
p=patch(x,y,'');
set(p,'FaceColor','flat','FaceVertexCData',c,'CDataMapping','scaled');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I want to write some information associated in the centre of each strip, for example, the width of each strip( different color)... etc
Meg Noah
Meg Noah 2025 年 8 月 5 日
figure(); y=[0 0 1 1;1 1 2 2]'; x=[0 10 10 0;0 10 10 0]'; c=[20 30]'; set(gca,'CLim',[0 40]); p=patch(x,y,''); set(p,'FaceColor','flat','FaceVertexCData',c,'CDataMapping','scaled');
xc = mean(x); % facet centers x-value
yc = mean(y); % facet centers y-value
text(xc(1),yc(1),['Width = ' num2str(max(x(:,1)-min(x(:,1))))]);
text(xc(2),yc(2),['Width = ' num2str(max(x(:,2)-min(x(:,2))))]);

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by