我目前正在使用 MATLAB 中的注释图像。为了沿轴标记一个特定点,我正在绘制带有剪裁的点,以便能够在轴限制之外绘制。但是,如果我包含一个补丁对象并使其透明,也就是说,我将渲染器从“画家”隐式更改为“OpenGL”,则通过裁剪绘制的对象将从图中消失。
请参阅下面的示例代码和图像。
关于解决方法或更好的实现的任何想法?我想要两全其美!
f1 = figure(1);clf
set(f1,'RendererMode','auto') %# Make sure renderer can change
%Plot objects
pLine = plot(0:0.1:1,0:0.1:1);hold on;
pointInside = plot(0.5,0.5,'v');
pointOutside=plot(0.5,1.01,'v','clipping','off'); %# Visible outside axes by clipping off.
patchHandle =patch([0.2;0.8;0.8;0.2],[0.2;0.2;0.8;0.8],ones(4,1));
patchHandle2 = patch([0.1;0.3;0.3;0.1],[0.7;0.7;0.9;0.9],zeros(4,1));
uistack(patchHandle2,'bottom')
axis([0 1 0 1])
colormap(summer)
%# Point outside now visible.
disp(get(f1,'renderer'))
%Make patch semi transparent
uistack(patchHandle,'top') %# Patch goes over line and point
set(patchHandle,'facealpha',0.7); %# Point and line visible again due to alpha
disp(get(f1,'renderer'))
%# Renderer has now changed and point outside no longer visible