View License

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

» Watch video

Highlights from
Candystripe a Plot and Legend

Be the first to rate this file! 6 Downloads (last 30 days) File Size: 4.59 KB File ID: #39994 Version: 1.0
image thumbnail

Candystripe a Plot and Legend



Adds candystriping to a given object, and automatically updates the legend entry as well.

| Watch this File

File Information

Candystripes patches
  candystripe creates a candystripe pattern to fill all patch-like objects
   in the current axis. Patch like objects are any objects that are plotted
   as patches in MATLAB. This includes, but is not limited to: bars, fills,
   patches, etc.
  candystripe(h) creates a candystripe pattern to fill the object specified
   by the handle H.
  candystripe(...,'param1',value1,'param2',value2,...) specifies optional
   parameters to be used in the candystripe creation. The parameters, data
   types, and default values are listed below.
   Optional Paramters:
    'Angle' scalar 45
        Specifies the angle in degrees at which the candystripes are to be
    'Color' [1x3] OR colorspec 'w'
        Specifies the color of the candystripes that are to be drawn
    'Units' string 'pixels'
        Specifies that units that are to be used when drawing the
        candystripes. This influences how the angle appears. For example,
        if the units are in pixels, a candystripe with a 45 degree angle
        will appear as such, regardless of what the data aspect ratio is.
        Valid options are {'inches' , 'centimeters' , 'normalized' ,
        'points' , 'pixels' , 'characters' , and 'native'}, where 'native'
        corresponds to the plot units
    'Width' scalar 10
        Specifies the width of the candystripe to be drawn. The units of
        this are specified by the optional input parameters UNITS. Note: By
        default, a cap is placed on how large candystripes may be. This is
        done so that the candystriping won't end up being a solid color.
  NOTE: If the object is already in the legend, candystripe will
   automatically update the thumbnail provided in the legend. However, if
   it is not in the legend, then the thumbnail will appear as the patch
   originally did.
    EXAMPLE 1: All patches with legend
        x = rand(3,1);
        y = rand(3,1);
    EXAMPLE 2: Bar plots
        data = rand(10,2);
        h = bar(data,'stacked');
        caxis([3 100])
    EXAMPLE 3: Thin candystipes at a 60 degree angle
        z = peaks;
        [c, h] = contourf(z);
    EXAMPLE 4: Patches with FaceColor set to interp
        t = 0:pi/5:2*pi;
        axis equal
        p = patch(sin(t),cos(t),1:length(t),'EdgeColor','k','LineWidth',1.5);
        data = randn(1000,10);
        xs = -3:0.1:3;
        h = hist(data,xs);
  J Sullivan January 2012

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)
21 Nov 2016 Christopher

I'm not sure, but it seems like this may require the Mapping Toolbox. I get an error when I run the first example (in the candystripe function) which says that the function poly2cw is not recognized. I looked it up and this seems to be in the Mapping Toolbox, which I do not have.

Comment only

Contact us