How to move a contourf plot created on a second axes on the baclground
4 views (last 30 days)
Show older comments
Hi, as sown in the example below, I create a imagesc plot and then on a new axe a contourf plot. How do you move the second axe on the background without having to create it first. I woulb be looking for the equivalent of uistack but for axes.
figure
ax1 = axes; % Create first set of axes
colormap(ax1,cool(10)); % First colormap
I1 = imagesc(peaks);
freezeColors
ax2 = axes; % Create second set of axes
axis(ax2,'off')
[C2, h2] = contourf(peaks,[0 0]);axis(ax2,'off')
colormap(ax2,gray)
set(h2,'LineWidth',2,'LineColor','k')
Thanks,
Matlab R2013a
0 Comments
Accepted Answer
Kelly Kearney
on 8 Oct 2015
Edited: Kelly Kearney
on 8 Oct 2015
uistack works for axes.
uistack(ax2, 'bottom');
Although in your particular example, you'd have to eliminate the axis color of ax1 and add some transparency to your image if you want to see through to ax2 now underneath.
figure
ax1 = axes; % Create first set of axes
colormap(ax1,cool(10)); % First colormap
I1 = imagesc(peaks);
freezeColors
ax2 = axes; % Create second set of axes
axis(ax2,'off')
[C2, h2] = contourf(peaks,[0 0]);axis(ax2,'off')
colormap(ax2,gray)
set(h2,'LineWidth',2,'LineColor','k')
uistack(ax2, 'bottom');
set(ax1, 'color', 'none');
set(I1, 'AlphaData', 0.9);
2 Comments
Mike Garrity
on 9 Oct 2015
In versions before R2014b, MATLAB's transparency support was a bit complex and confusing. It depended on a number of things. The short version of the story is that it only worked when the Renderer property of the figure was set to opengl, and even then there were a few systems which had problems with it, such as that Macintosh referred to in that other answer.
In R2014b or higher, support for transparency is a lot more uniform. It should work with either renderer, and the only transparency feature I know of that is missing on some machines is the 3D sorting feature I describe in this blog post .
More Answers (0)
See Also
Categories
Find more on Purple in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!