Pergunta

I have a script:

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])

With this code I'm getting graph like this: enter image description here

I'd like to print on the graph also values of min and max value. How can I do this? It seems to me that I should use "text" function, but I cannot figure out parameters for it.

Foi útil?

Solução

Indeed, you can use 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));

You may need to adjust the x/y coordinates before passing them to text.

Outras dicas

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)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top