Candystripe a Plot and Legend

버전 1.0.0.0 (4.59 KB) 작성자: Jonathan Sullivan
Adds candystriping to a given object, and automatically updates the legend entry as well.
다운로드 수: 632
업데이트 날짜: 2013/1/24

라이선스 보기

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

인용 양식

Jonathan Sullivan (2024). Candystripe a Plot and Legend (https://www.mathworks.com/matlabcentral/fileexchange/39994-candystripe-a-plot-and-legend), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2012b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Data Distribution Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0