Textures for bar plots

6 ビュー (過去 30 日間)
gfudenberg
gfudenberg 2011 年 3 月 21 日
Hello, does anyone know of a way to add textures (eg. diagonal hatches) to a bar plot without making a bitmap copy of the figure, but keeping it as a .fig? (ie. a different than http://www.mathworks.com/matlabcentral/fileexchange/1736-hatched-fill-patterns)

回答 (2 件)

Matt Fig
Matt Fig 2011 年 3 月 22 日
You could do it with LINE objects, though it would take a little fiddling:
B = bar([3 4 5],.75)
xd = get(B,'xdata')
yd = get(B,'ydata')
bw = get(B,'barwidth')
for ii = 1:5
line(xd(1)+[-bw bw]/2,[0 1]+(ii-1)/2,'linewidth',5,'color','k')
end
line(xd(1)+[-bw/2 0],[2.5 3],'linewidth',5,'color','k')
line(xd(1)+[0 bw/2],[0 .5],'linewidth',5,'color','k')

Andrew Newell
Andrew Newell 2011 年 3 月 22 日
Hatchfill, from the File Exchange, finds the patch objects and hatches them. It seems a little buggy, though (at least when applied to bar plots).
EDIT: I see why it has problems with bar plots. Each set of bars of the same color form one patch object.

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by