Borrar filtros
Borrar filtros

painters renderer ignoring uistack and z values in R2014b

1 visualización (últimos 30 días)
I'm writing a script that will be used on R2012b and R2014b. It works wonderfully in R2012b, but R2014b is ignoring z values and ignoring uistack order. Oddly enough, the problem only arises when I give any of the objects a z value. Here is an example:
figure('renderer','painters')
h0 = imagesc(peaks(100));
hold on
[C,h1] = contour(peaks(100),'color',.4*[1 1 1]);
clabel(C,h1);
h2 = plot(1:100,1:100,'b-','linewidth',3);
h3 = plot(1:100,(1:100).^1.2-30,'r','linewidth',3);
h4 = text(30,50,'some text near the top','color',[.98 .45 .02]);
h5 = text(25,75,1,'this text should be on top of everything');
Using uistack(h5,'top') does not fix the problem.
I don't understand why, but if I set the z value in h5 to 0, the problem goes away. Does anyone know why this is happening or how I can work around it? I need to stick with the painters renderer.

Respuesta aceptada

Mike Garrity
Mike Garrity el 19 de Nov. de 2015
Editada: Mike Garrity el 19 de Nov. de 2015
You need to learn about the SortMethod property on the axes. I talked about it in this post on the MATLAB Graphics blog. Because you put one text object at a different Z value from the rest of the scene, the axes guessed that you probably wanted depthsort. It sounds like you actually want childorder.
  1 comentario
Chad Greene
Chad Greene el 19 de Nov. de 2015
That's it! The fix really is as easy as
ax = gca;
ax.SortMethod = 'childorder';
Thanks Mike!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by