View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
hfill and vfill

Be the first to rate this file! 5 Downloads (last 30 days) File Size: 58.3 KB File ID: #43090 Version: 1.2
image thumbnail

hfill and vfill


Chad Greene (view profile)


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.


hfill([ystart yend])
h = hfill(...)


hfill(scalarValue) places a horizontal line along y = scalarValue.

hfill([ystart yend]) fills a horizontal shaded region bounded by ystart and yend.

hfill([ystart1,yend1,ystart2,yend2,...,ystartn,yendn]) fills multiple horizontal regions.

hfill(...,ColorSpec) defines the face color of the patch(es) created by hfill. ColorSpec can be one of the Matlab color names (e.g. 'red'), abbreviations (e.g. 'r', or rgb triplet (e.g. [1 0 0]). ColorSpec may also be 'gray'.

hfill(...,ColorSpec,'PatchProperty','PatchValue') defines patch properties such as 'EdgeColor' and 'FaceAlpha'.

hfill(...,'bottom') places the newly created patch(es) at the bottom of the uistack.

h = hfill(...) returns handle(s) of newly created patch objects.


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

Chad Greene (view profile)

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');

Comment only
19 Aug 2013 1.1

Added hfill and the stacking command.

01 Aug 2014 1.2

Simplified syntax for plain vertical or horizontal lines, added an example file.

Contact us