The histogram2
function (added in R2015b) has the DisplayStyle
optional argument, which controls whether the output is displayed using "bars" (of uniform color but different height) or "tiles" (with the same height of 0, but with different colors), as demonstrated below:
rng(1337); X = rand(100,1)-0.5; Y = randn(100,1); rng('default');
figure();
subplot(1,2,1); hH(1) = histogram2(X, Y, 'DisplayStyle', 'bar3');
subplot(1,2,2); hH(2) = histogram2(X, Y, 'DisplayStyle', 'tile');
I would like to combine the two modes, to get bars with different height which also have different colors. As mentioned, I tried using the 'DisplayStyle'
option, but it changes too many visual elements at the same time. Can anybody suggest a way to get what I want?
I'd very much like the solution to be a histogram2
object (as opposed to e.g. bar3
), as these are much more convenient to work with later on.