I want to export a Matlab figure with 2 y-axis to a tikz-plot with matlab2tikz. The figure is shown in the following picture.enter image description here

The blue plot belongs to the left y-axis and the 2 red plot belong to the right y-axis (Sorry, that there are not axis labels ). I used the command


to export the figure. Unfortunately only the 2 red plots with the corresponding y-axis show up in the corresponding image in the final pdf-file. When I open the 'pcToDcComp.tex' file with a editor, it shows me that only the data of the two red plots is in the file. There is no 'addplot{}' command for the blue plot, neither is there some code which defines a second y-axis. However, when I enter in Matlab the command

yyaxis left

and afterward execute the matlab2tikz-command again with the exact same input arguments, the generated Latex-file only contains data for the blue plot. I already tried a workaround where I generated two seperate files, one for each y-axis. Then I copied the whole '\begin{axis}....\end{axis}'-part of one file and inserted it in the tikzpicture-environment of the other file. But in the resulting picture, one y-axis plot is hidden by the second one. How can I do it properly?

  • If you simply want to see how to handle a pgfplot with two y axes, see tex.stackexchange.com/questions/62291/… for example). – John Kormylo Jul 20 '16 at 16:17
  • @JohnKormylo Well, I hoped there would be a way to do it directly from matlab2tikz, but your recommendation is also doing the trick. – zufall Jul 24 '16 at 17:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.