![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/290093/image.png)
How to remove dot from zero error bars
4 次查看(过去 30 天)
显示 更早的评论
The MATLAB script below produces the following bar chart:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/290078/image.jpeg)
How do I remove the dot on the bars with zero error as I would like the bar to have no error calculated but the dot suggests there is 0% error for these readings.
x=categorical({'Q3','Q6','Q10','Q15','Q30','Q50'});
z=[2.891586318,1.99422657,1.907652812,4.71298388,6.007681496,6.718181667;3.229392123,3.36482536,4.089746011,5.204662107,6.761377397,7.978099976];
y=transpose(z);
a=[0.167797,0.314574,0.081018,0,0.116596,0;0,0.173132,0,0.231752,1.15677,1.204734];
errorplus=a;
errorminus=errorplus;
figure;
bar(x,y);
hBar = bar(y, 0.8);
for k1 = 1:size(y,2)
ctr(k1,:) = bsxfun(@plus, hBar(k1).XData, hBar(k1).XOffset');
ydt(k1,:) = hBar(k1).YData;
end
hold on
errorbar(ctr, ydt, errorplus, '.k')
hold off
ylabel('Signal Intensity','FontSize',18)
set(gca,'linewidth',2,'FontSize',14)
ylim([0 10]);
set(gca,'XTickLabel',cellstr(x))
0 个评论
采纳的回答
Mehmed Saad
2020-5-4
编辑:Mehmed Saad
2020-5-4
You are telling MATLAB to set color to black and marker to dot.
'.k'
Replace it with
'k'
Also set linestyle of errorbar to 'none'.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/290093/image.png)
2 个评论
Mehmed Saad
2020-5-4
编辑:Mehmed Saad
2020-5-4
within errorbar command like
errorbar(ctr, ydt, errorplus,'k','LineStyle','none')
to call it by
handle_errorbar.LineStyle
you have to save errorbar handle in some variable just like you save hbar. and you have to set LineStyle to none for each error bar in that case. so it is better the first way
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!