Candystripe a Plot and Legend

Adds candystriping to a given object, and automatically updates the legend entry as well.
630 téléchargements
Mise à jour 24 jan. 2013

Afficher la licence

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

Citation pour cette source

Jonathan Sullivan (2024). Candystripe a Plot and Legend (https://www.mathworks.com/matlabcentral/fileexchange/39994-candystripe-a-plot-and-legend), MATLAB Central File Exchange. Récupéré le .

Compatibilité avec les versions de MATLAB
Créé avec R2012b
Compatible avec toutes les versions
Plateformes compatibles
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Publié le Notes de version
1.0.0.0