interference with marker and patch?

4 views (last 30 days)
Alison
Alison on 11 Nov 2013
Edited: Alison on 13 Nov 2013
Hi,
I am trying to shade part of a figure in a subplot gray. I am using patch with the FaceVertexCData properties, and it works, as long as I include a subplot somewhere in the figure that has markers defined. If I take out that subplot, or try to use this code with a plot that is a line only, patch causes my plot to go away and some weird lines appear.
I have tried moving the patch call to different times during the code sequence, and by process of elimination have determined that it is 'Marker', 'o' (or any symbol, as long as I specify it) that causes patch to work, for all the subplots in the figure, not just the one where I've defined it. If that's not listed anywhere, it won't work. I've also tried defining Marker and then clearing the figure before plotting the line, or trying to plot transparent markers, and that hasn't worked.
Using the XYZ version of patch doesn't seem to work as well, partially because I can't get the syntax right, and partially because I have multiple subplots and I don't know the exact coordinates of the shading area for each one. When I use the vertices method, I input values well above/below any of the axis values, and it seems to just fill in to the extent of that subplot like I want it to.
v = [ceeser(1) -10 0; ceeser(1) 1550 0; ceeser(2) 1550 0; ceeser(2) -10 0];
f = [1 2 3 4];
fvc = [.8 .8 .8;.8 .8 .8;.8 .8 .8;.8 .8 .8];
patch('Vertices',v,'Faces',f,'FaceVertexCData',fvc,'FaceColor','flat','EdgeColor','flat')
Can anyone tell me what I am doing wrong? I can't find any forums where someone has had a similar problem.
Thank you, Alison (Matlab 2007a on XP... I need to run it on this older computer, but I have also tried on newer versions and seem to get the same issues)

Accepted Answer

Kelly Kearney
Kelly Kearney on 11 Nov 2013
Guessing perhaps an OpenGL issue ( http://www.mathworks.com/help/matlab/ref/opengl.html). Try placing:
set(gcf, 'renderer', 'zbuffer')
after your patch command.
  1 Comment
Alison
Alison on 13 Nov 2013
Edited: Alison on 13 Nov 2013
Thank you! That worked, with only a slight decrease in figure appearance. I was going around in circles and hadn't gotten close to that, you saved me.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!