I'm attempting to plot two 'contourf()' plots side by side with different color maps. I had done this quite successfully using the 'set(myAxes(2), 'Visible','off');'. However, the addition of 'xlabel' and 'ylabel' to one but not both set of axes moves the bounding boxes of the plot and they no longer match up. So instead I need to plot the second 'contourf()' not with no axes or background, but with a transparent one.
Previous to 2014b solutions like this one could be used, by directly accessing the children of the 'countourf()' plot. Since the change in 2014b to a different set of return variables for 'countourf()' this solution no longer works, and the children of the countour plot it's self can't be accessed.
I have found that for '[C,h] = countourf();' you can access h.FacePrims and their .ColorType and .ColorData in order to set the alpha of the contours themselves to be transparent, but I have been unable to discover a similar way to access the background of the plot to set it to be transparent.
For reference, my code is below. It is the second 'countourf()' whose background I'd like to be transparent.
figure('units','normalized');ax(1) = axes;[C1,h1] = contourf(Xgrid,Zgrid,foc2psIonDenCut,color.contVec);set(h1,'LineStyle','None');colormap(ax(1),color.cmapBR);caxis(ax(1),[color.contMin color.contMax]);xlim(ax(1),[-2 4]);ylim(ax(1),[-52 52]);set(ax(1),'YTick',[-50:25:50]);xlabel('Z Dimension [\mum]');ylabel('X Dimension [\mum]');% Background Rectangle
rectangle('Position',[-2 -52 6 52],'FaceColor',[0.9 0.9 0.9],'LineStyle','none');ax(2) = axes;[C2,h2] = contourf(Xgrid,Zgrid,def2psIonDenCut,color.contVec);set(h2,'LineStyle','None');colormap(ax(2),color.cmapPK);caxis(ax(2),[color.contMin color.contMax]);xlim(ax(2),[-2 4]);ylim(ax(2),[-52 52]);set(ax(2),'YTick',[-50:25:50]);xlabel(ax(2),'Z Dimension [\mum]');ylabel(ax(2),'X Dimension [\mum]');%set(ax(2), 'Visible','off'); %This is where in previous versions I'd turn the second axes off.
Best Answer