【发布时间】:2016-04-26 14:58:43
【问题描述】:
我正在绘制两个相互重叠的频率条形图,我想让其中一个条形图透明。我试过这个:
[n,xout] = hist(data1,10); %Use 10 bins for the histogram
B1 = bar(xout,n/sum(n),'b'); %relative frequency is n/sum(n)
hold on
[n,xout] = hist(data2,10); %Use 10 bins for the histogram
B2 = bar(xout,n/sum(n),'r'); %relative frequency is n/sum(n)
ch = get(B2,'child');
set(ch,'facea',.4)
但是,绘制的第二个图似乎并不透明。我有什么遗漏吗?
编辑
get(B2)的输出:
Annotation: [1x1 matlab.graphics.eventdata.Annotation]
BarLayout: 'grouped'
BarWidth: 0.8000
BaseLine: [1x1 Baseline]
BaseValue: 0
BeingDeleted: 'off'
BusyAction: 'queue'
ButtonDownFcn: ''
Children: []
Clipping: 'on'
CreateFcn: ''
DeleteFcn: ''
DisplayName: ''
EdgeColor: [0 0 0]
FaceColor: 'flat'
HandleVisibility: 'on'
HitTest: 'on'
Horizontal: 'off'
Interruptible: 'on'
LineStyle: '-'
LineWidth: 0.5000
Parent: [1x1 Axes]
PickableParts: 'visible'
Selected: 'off'
SelectionHighlight: 'on'
ShowBaseLine: 'on'
Tag: ''
Type: 'bar'
UIContextMenu: []
UserData: []
Visible: 'on'
XData: [1x10 double]
XDataMode: 'manual'
XDataSource: ''
YData: [0.5333 0.1778 0.0444 0.0889 0.0889 0.0222 0 0.0222 0 0.0222]
YDataSource: ''
【问题讨论】: