1 | function[fillhandle,msg]=jbfill(xpoints,upper,lower,color,edge,add,transparency)
|
---|
2 |
|
---|
3 | %+
|
---|
4 | %
|
---|
5 | % ========
|
---|
6 | % jbfill.m
|
---|
7 | % ========
|
---|
8 | %
|
---|
9 | % .. function:: jbfill(xpoints,upper,lower,color,edge,add,transparency)
|
---|
10 | %
|
---|
11 | % DESCRIPTION
|
---|
12 | % ===========
|
---|
13 | %
|
---|
14 | % cf. source code
|
---|
15 | %
|
---|
16 | % EVOLUTIONS
|
---|
17 | % ==========
|
---|
18 | %
|
---|
19 | % $Id$
|
---|
20 | %
|
---|
21 | % $URL$
|
---|
22 | %
|
---|
23 | % - fplod 20110705T125628Z cratos.locean-ipsl.upmc.fr (Linux)
|
---|
24 | %
|
---|
25 | % * minimal header
|
---|
26 | %
|
---|
27 | %-
|
---|
28 |
|
---|
29 | %USAGE: [fillhandle,msg]=jbfill(xpoints,upper,lower,color,edge,add,transparency)
|
---|
30 | %This function will fill a region with a color between the two curves or vectors provided
|
---|
31 | %using the Matlab fill command.
|
---|
32 | %
|
---|
33 | %fillhandle is the returned handle to the filled region in the plot.
|
---|
34 | %xpoints= The horizontal data points (ie frequencies). Note length(Upper)
|
---|
35 | % must equal Length(lower)and must equal length(xpoints)!
|
---|
36 | %upper = the upper curve values (data can be less than lower)
|
---|
37 | %lower = the lower curve values (data can be more than upper)
|
---|
38 | %color = the color of the filled area
|
---|
39 | %edge = the color around the edge of the filled area
|
---|
40 | %add = a flag to add to the current plot or make a new one.
|
---|
41 | %transparency is a value ranging from 1 for opaque to 0 for invisible for
|
---|
42 | %the filled color only.
|
---|
43 | %
|
---|
44 | %John A. Bockstege November 2006;
|
---|
45 | %Example:
|
---|
46 | %USAGE: [fillhandle,msg]=jbfill(xpoints,upper,lower,color,edge,add,transparency)
|
---|
47 | % a=rand(1,20);%Vector of random data
|
---|
48 | % b=a+2*rand(1,20);%2nd vector of data points;
|
---|
49 | % x=1:20;%horizontal vector
|
---|
50 | % [ph,msg]=jbfill(x,a,b,rand(1,3),rand(1,3),0,rand(1,1))
|
---|
51 | % grid on
|
---|
52 | % legend('Datr')
|
---|
53 | if nargin<7;transparency=.5;end %default is to have a transparency of .5
|
---|
54 | if nargin<6;add=1;end %default is to add to current plot
|
---|
55 | if nargin<5;edge='k';end %dfault edge color is black
|
---|
56 | if nargin<4;color='b';end %default color is blue
|
---|
57 |
|
---|
58 | if length(upper)==length(lower) && length(lower)==length(xpoints)
|
---|
59 | msg='';
|
---|
60 | filled=[upper,fliplr(lower)];
|
---|
61 | xpoints=[xpoints,fliplr(xpoints)];
|
---|
62 | if add
|
---|
63 | hold on
|
---|
64 | end
|
---|
65 | fillhandle=fill(xpoints,filled,color);%plot the data
|
---|
66 | set(fillhandle,'EdgeColor',edge,'FaceAlpha',transparency,'EdgeAlpha',transparency);%set edge color
|
---|
67 | if add
|
---|
68 | hold off
|
---|
69 | end
|
---|
70 | else
|
---|
71 | msg='Error: Must use the same number of points in each vector';
|
---|
72 | end
|
---|