Code covered by the BSD License  

Highlights from
Candystripe a Plot and Legend

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

Candystripe a Plot and Legend

by

 

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

| Watch this File

File Information
Description

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:
    PARAMETER NAME DATA TYPE ORIGINAL DEFAULT VALUE
 
    'Angle' scalar 45
        Specifies the angle in degrees at which the candystripes are to be
        drawn.
 
    '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);
        figure
        patch(x,y,'r');
        legend('Triangle')
        candystripe;
 
    EXAMPLE 2: Bar plots
        data = rand(10,2);
        figure
        h = bar(data,'stacked');
        caxis([3 100])
        legend('Current','Future')
        candystripe(h(2));
 
    EXAMPLE 3: Thin candystipes at a 60 degree angle
        z = peaks;
        figure
        [c, h] = contourf(z);
        candystripe(h,'Units','native','width',1,'Angle',60)
 
    EXAMPLE 4: Patches with FaceColor set to interp
        t = 0:pi/5:2*pi;
        figure
        axis equal
        p = patch(sin(t),cos(t),1:length(t),'EdgeColor','k','LineWidth',1.5);
        candystripe(p)
 
    EXAMPLE 5
        data = randn(1000,10);
        xs = -3:0.1:3;
        figure;
        h = hist(data,xs);
        candystripe(h(5:10));
 
  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.

Contact us