Code covered by the BSD License  

Highlights from
hfill and vfill

Be the first to rate this file! 26 Downloads (last 30 days) File Size: 17.7 KB File ID: #43090
image thumbnail

hfill and vfill



15 Aug 2013 (Updated )

Simply create horizontal or vertical shaded sections of a plot.

| Watch this File

File Information

h = vfill(xbounds,ColorSpec,varargin) creates fill objects bounded by the values xbounds. ColorSpec defines the color of the fill objects. Optional varargin can be used to set edgecolor, transparency, etc.

Optional output h gives the handle(s) of each patch object.

The left plot in the example image above was produced with these four lines:
vfill([5 15; 30 60],'g','facealpha',.4,'edgecolor','r','linestyle','--')
vfill([80 90],'gray')
vfill([65 75],'r','bottom')

xbounds defines the bounding values of area(s) to be filled. Can be in any of the following forms:
xbounds = [xstart1,xend1,xstart2,xend2,...,xstartn,xendn]

xbounds = [xstart1 xend1;
          xstart2 xend2;
          xstartn xendn];

xbounds = [xstart1 xstart2 ... xstartn;
           xend1 xend2 ... xendn];

xbounds = scalarvalue places a vertical line at scalarvalue, similar to the hline or vline functions already available on file exchange.

ColorSpec Defines the color of the patch(es) to be created. Can be RGB value (e.g., [0 1 0]), short name (e.g., 'g'), or long name (e.g. 'green'). Also supports the 'gray' for 50% gray.

varargin List of name-value pairs such as 'facealpha',.5,'edgecolor','r'. Can also include the tag 'bottom' to send the patch to the back.


Hline And Vline and Improved 'Vline' inspired this file.

Required Products MATLAB
MATLAB release MATLAB 8.0 (R2012b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
15 Aug 2013 Chad Greene

Tip: If you like the example image, but you'd prefer the gray box to be behind your data instead of on top of it, reorder the stack like this:

h = vfill([80 90],'gray');

19 Aug 2013

Added hfill and the stacking command.

Contact us