annotate graphics/multibar.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 547c48f3a008
children
rev   line source
samer@59 1 % multibar - Multiple bar plots with different domains.
samer@59 2 %
samer@60 3 % multibar :: plotfn, cells(pair([[N]->Dom],[[N]])), options -> handle.
samer@60 4 % plotfn is any plotting function like bar, plot, area stairs etc
samer@60 5 % that takes two arrays of X and Y values.
samer@60 6 function h=multibar(F,D,varargin)
samer@59 7 X=flatten(foldl(@union,[],map(@fst,D)));
samer@60 8 h=F(X,cellcat(2,map(@(d)expand(X,d),D)),varargin{:});
samer@59 9 end
samer@59 10
samer@59 11 function Y2=expand(X,Data)
samer@59 12 Y2=maprows(@get_or_nan,X);
samer@59 13 function y=get_or_nan(x)
samer@59 14 [dummy,i]=find(Data{1}==x);
samer@59 15 if isempty(i), y=nan; else y=Data{2}(i); end
samer@59 16 end
samer@59 17 end
samer@59 18
samer@59 19