Closed briochemc closed 2 years ago
The contourfcmap function calls my pcolorbar function to create the psuedo-colorbar. That psuedo-colorbar consists of a (visible) axis with a patch object that mimics a colorbar, as well as an actual (not visible) colorbar that it uses to determine the position. This pairing allows you to reposition the psuedo-colorbar just like a real one:
cmap = jet(10);
clev = linspace(-2,2,11);
[X1,Y1,Z1] = peaks;
Z2 = membrane;
[X2,Y2] = ndgrid(1:size(Z2,1), 1:size(Z2,2));
tiledlayout(2,1);
nexttile
h1 = contourfcmap(X1,Y1,Z1,clev,cmap, 'method', 'calccontour', ...
'lo', ones(1,3)*0.2, ...
'hi', ones(1,3)*0.8, ...
'cbarloc', 'eastoutside'); % choosing 'eastoutside' puts the ticks on the correct side
nexttile
h2 = contourfcmap(X2,Y2,Z2,clev,cmap, 'method', 'calccontour');
h1.cb.cb.Layout.Tile = 'east'; % <- change colorbar to east of both tiles
Do you have a small example where two subplots can share the same (unique) colorbar?
Here is a "modern" example from the docs:
How would one go about to do something similar with contourfcmap?