如何使用errorbar打印出max和min值?

时间:2014-04-23 15:12:18

标签: matlab plot octave

我有一个脚本:

w = dlmread("./fscore_wc.txt", "\t");
e = dlmread("./variance_wc.txt", "\t");
x = [0.1 0.2 0.3 0.4 0.5];
%h=figure('visible','off');
[row col] = size(w);^M
errorbar(x, w(12, 1:col), e(12, 1:col), '-ok');
xlabel("Learning set ratio");
ylabel("F-score");
axis([0.0 0.6 0.75 0.9])

使用此代码,我得到的图形如下: enter image description here

我想在图表上打印最小值和最大值的值。我怎样才能做到这一点?在我看来,我应该使用“文本”功能,但我无法找出它的参数。

2 个答案:

答案 0 :(得分:1)

确实,您可以使用text

y =  w(12, 1:col);
ey = e(12, 1:col);

maxerr = y + ey;
minerr = y - ey;

# Add annotations with text(xs, ys, texts)
text(x, maxerr, cellfun('num2str', num2cell(maxerr), 'UniformOutput', false));
text(x, minerr, cellfun('num2str', num2cell(minerr), 'UniformOutput', false));

您可能需要先调整x / y坐标,然后再将其传递给text

答案 1 :(得分:0)

x = [1 2 3 4 5];
ymin = [0.01 0.02 0.03 0.04 0.05]; % lower error bar position
ymax = [0.02 0.03 0.04 0.05 0.06]; % upper error bar position
% draw error bar from minimum value to maximum value
errorbar(x,(ymin+ymax)/2,(ymax-ymin)/2)
相关问题