File Exchange

image thumbnail

dropshadow - Drop Shadow class for plot objects

version 1.0 (4.6 KB) by

Adds a dropshadow to plot objects.

2 Downloads

Updated

View License

Every now and then your crude and harsh Matlab plots can benefit from some graphical enhancements. This class adds a fully customisable dropshadow to the plot objects in your axes. It takes a "snapshot" of the current axes and renders a dropshadow image using 2D convolution with a Gaussian kernel. Still, the figure can be exported to a vector graphics format, making it ideal for printed reports or PDFs.

Usage:
ShadowObj = dropshadow(hAxes) creates a dropshadow object for the plot objects in the specified axes. The shadow image is rendered using 2D convolution of a Gaussian kernel based on the properties Color, Angle, Distance, Spread and Size. The original plot objects are kept, such that the figure can still be exported to a vector graphics format such as EPS or PDF.

ShadowObj = dropshadow(hAxes,'Prop1',Value1,...) creates the dropshadow and sets the specified properties.

The dropshadow object is updated whenever a change is made to one of the properties. The object is deleted upon axes deletion.

Note that the shadow is always put as a 2D image in the background of the plot axes, regardless of 3D rotations.

Known issues:
The current implementation uses the java.awt.Robot to make a snapshot. This will not work with docked figures. A workaround is to use the built-in getframe function, which is activated by setting the hidden property ShadowObj.SnapMethod = 'getframe'. Suggestions for more robust implementations are welcome!

Comments and Ratings (6)

Ashley

Ashley (view profile)

This is a great lightweight helper. I want to get a mesh to throw a shadow and I'm not winning. I see that there is a private function that does a drop shadow for a ShadowObj. Is this the right idea? how do I access it if so?

Yes, I'm using the 2014b version. And thanks, I'll try it on an older version.

Hi Janneke, I guess you are using Matlab version 2014b or newer? The function appears to be incompatible with the updated graphics system (HG2). I haven't been able to fix this; to use it I would suggest to use a Matlab version not newer than 2014a.

I am trying to use the dropshadow effect, using the given example in the script. When I run it, I get the following error:

Error using dropshadow (line 86)
Parent must be an axes handle.

How can I fix this?

Frank

Frank (view profile)

Great effect! Just make sure the 'units' of root are pixels before getting the monitor size.

Frank

Frank (view profile)

MATLAB Release
MATLAB 7.14 (R2012a)
Acknowledgements

Inspired by: getscreen

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

» Watch video