From: Joshua Arnott on
Hi,

I'm having some trouble plotting (semi-)transparent patches. The problem is occuring in a more complicated plot, for which I'm having trouble recreating the exact problem, but here is a simpler version (partially) demonstrating the issue.

% patchbug.m
figure(); clf
grid on
z = -1;
ph = patch([-5 -5 5 5],[-5 5 5 -5],z*ones(4,1),'k'); % draw patch
set(ph,'FaceAlpha',0.7) % change patch alpha
xlim([-4 4]); ylim([-4 4]); % limits are completely within patch (no edges!)

When z = 1, the semi-transparent patch displays as expected (grey-ish with gridlines showing through). However, if z = -1, the patch does not display; it's as if it wasn't plotted. This occurs when none of the patch edges are visible within the given xy limits.

I came across this while plotting ~100 patches, highlighting different sections of two line() plots. I've been trying to plot the patches on z=1, one line on z=2 and another on z=3, as the renderer was becoming confused which was on top (I previously expected it just to be a case of what came first). The main plot doesn't have anything z < 1, and demonstrates the issue above, but I can't seem to reproduce it without the entire plot.

What's going on here? I'm very confused.

Tested on 2009b.

Josh.