Clipping property doesn't work?

4 次查看(过去 30 天)
It seems that clipping property doesn't work for plot objects like bar, stem, stairs.
See simple exapmle:
plot(1:10,5:-0.5:0.5,'r')
xlim([0 10])
ylim([0,5])
hold on
h=plot(1:10,2:.5:6.5);
set(h,'Clipping','off')
The result is as follows:
And it is OK.
But if i change second plot command to bar, stairs or stem, the results are:
Is this the correct behavior of MATLAB?

采纳的回答

dpb
dpb 2013-11-21
编辑:dpb 2013-11-21
Well, "correct" is in eyes of beholder...it is the behavior as implemented; whether the other plot types should inherit 'clipping' property state from other is a design decision.
After your above from the command line...
>> hb=bar(1:10,2:.5:6.5);
>> get(hb)
Annotation: [1x1 hg.Annotation]
DisplayName: ''
HitTestArea: 'off'
BeingDeleted: 'off'
ButtonDownFcn: []
Children: 189.0079
Clipping: 'on'
...
>> get(get(hb,'children'))
AlphaDataMapping = scaled
Annotation = [ (1 by 1) hg.Annotation array]
CData = [ (4 by 10) double array]
CDataMapping = scaled
...
BeingDeleted = off
ButtonDownFcn =
Children = []
Clipping = on
...
...
So, to turn the effective clipping property for these child objects you've got to go handle-diving and get to the bottom...
>> set(get(hb,'children'),'clipping','off')
will do so for the bar plot; similar machinations for the others.
ADDENDUM:
Note that for consistency the behavior is similar in that plot returns a line object handle whereas the others are composite objects the actual data drawn of which is at a lower level. Hence the need to "handle-dive" into the guts to get the point level at which the 'clipping' property needs must be set.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by