File Exchange

image thumbnail


version (882 Bytes) by Martyn Dorey
Function creates a shaded rectangle.


Updated 02 Mar 2005

No License

Do you want to create box plots with shaded bars?
Do you want to fill the graph area before you plot?
Do you want an example which interpolates colour from left to right or up and down?

Your chart will look alot better if you fill the plot area before you chart.

Try this function to spice up your graph back grounds or create shaded 'control ranges' on a chart.

[hPatch, hLine] =drawShadedRectangle(vecXMinMax,vecYMinMax,vecC1,vecC2,vecC3,vecBorderColor,typeHorzVert)

For example:
drawShadedRectangle([0 3],[0 3],[0.95 0.95 1],[0.75 0.75 1],[0.95 0.95 1],[0 0 0.5],'horizontal')

will create a box 3x3 with a white/light blue/white gradient

hold on
drawShadedRectangle([0 1],[0.5 1],[0 0 0.5],[0.75 0.75 1],[0 0 0.5],[0 0 0.5],'horizontal')

Will draw a shaded bar above the background. So it looks just like an excel chart.


Cite As

Martyn Dorey (2020). drawShadedRectangle (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (6)

Stuart Anderson

Exceptionally useful ! The documentation could be expanded to define the individual terms more precisely, such as listing all the options for the shading, and the maximum number of colour transitions, but overall a really excellent contribution. Thank you Martyn.

K Garrison

Just what I needed

Youri Who

Julien Emile-Geay

I love it. It's phat.

T-Bone Williams

Works awesome...

Arthur Mobile

Useful, thanks.


Tidying up messy code

MATLAB Release Compatibility
Created with R14SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux