Filter löschen
Filter löschen

painters renderer ignoring uistack and z values in R2014b

1 Ansicht (letzte 30 Tage)
Chad Greene
Chad Greene am 19 Nov. 2015
Kommentiert: Chad Greene am 19 Nov. 2015
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.

Akzeptierte Antwort

Mike Garrity
Mike Garrity am 19 Nov. 2015
Bearbeitet: Mike Garrity am 19 Nov. 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 Kommentar
Chad Greene
Chad Greene am 19 Nov. 2015
That's it! The fix really is as easy as
ax = gca;
ax.SortMethod = 'childorder';
Thanks Mike!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by