nschloe/matlab2tikz — Issue #70: Legend bug: wrong line width and color
Author: brupp
Created: 2012-02-17 12:45:56+00:00
State: open

First, let me say thank you for this great script!

I experience the following issue (on latest release and latest git source): I am drawing two plots with errorbar() and in addition add horizontal errorbars with the herrorbar() function from FileExchange (http://www.mathworks.com/matlabcentral/fileexchange/3963-herrorbar).

When I now add a legend to the graph, the little indicator lines before the legend text have the wrong line width and color.

Code to reproduce the issue:

figure
hold on
X = 1:10;
Y = 1:10;
err = repmat(0.2, 1, 10);
h1 = errorbar(X, Y, err, 'r');
h_vec = herrorbar(X, Y, err);
for h=h_vec
set(h, 'color', [1 0 0]);
end
h2 = errorbar(X, Y+1, err, 'g');
h_vec = herrorbar(X, Y+1, err);
for h=h_vec
set(h, 'color', [0 1 0]);
end
legend([h1 h2], {'test1', 'test2'})
hold off
matlab2tikz('test.tex');