0

I have a matlab code, creating a set of figures, which I want to export to Latex using matlab2tikz. Unfortunately I can't figure out how to export without a legend, using Matlab R2019b and matlab2tikz 1.0.0.0.

I could remove the legendentries manually in the .tex files, however I have very many files and wanted to have a toolchain, which works fully automated.

Here is a simple example

figure()
hold on;
plot(sin(0:.01:pi));
hold off
matlab2tikz('test.tex');

Stopping the code before the matlab2tikz export, the plot does not have a legend. Unfortunately, it is added with the matlab2tikz command. Can anybody help?

Edit: Thanks Torbjørn, the bug report lists a solution, however, settings like 'NumColumns',3 seem not be supported. May this result in the change or is there another trick?

  • 1
    Looks like there is an open bug report about this: https://github.com/matlab2tikz/matlab2tikz/issues/1056 (or even two). That first one has a suggestion for a fix, you could try that. – Torbjørn T. Apr 09 '20 at 08:13
  • This seems to work for me, here is the direct link to the commit: https://github.com/matlab2tikz/matlab2tikz/pull/1064/files/76c8bc850b4d6fa2434730348783487a8faf41b4 Thank you very much. – Martin Herrmann Apr 09 '20 at 08:35

1 Answers1

1

I put the following code:

fleg = legend('figure()');
set(fleg,'visible','off')

matlab2tikz('test.tex')

Which works for me.

schoekling
  • 3,142
Leandro
  • 11
  • 1