Candystripe a Plot and Legend
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
Cite As
Jonathan Sullivan (2024). Candystripe a Plot and Legend (https://www.mathworks.com/matlabcentral/fileexchange/39994-candystripe-a-plot-and-legend), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Graphics > 2-D and 3-D Plots > Data Distribution Plots >
- MATLAB > Graphics > Formatting and Annotation > Labels and Annotations > Annotations >
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |