1

I got a problem, which I am somehow not able to solve for days. I created a graph in Matlab and wanted to import it in my LaTeX document. This is my MATLAB Code.

figure();
subplot(2,1,1);
L_input = L_input ./ L_D;
x_axis = repmat(t.',1,numel(L_input));
y_axis = repmat(L_input, numel(t), 1);
z_axis = ergebnis;
plot = plot3(x_axis,y_axis,z_axis, 'k');
view(45,45);
xlim([-10 10]);
ylim([0 L_input(end)]);
xlabel('Verzögerung t');
ylabel('Distanz z/L_D');
zlabel('Intensität A');
grid;

% second Image
subplot(2,1,2);
imagesc(t,L_input,abs(ergebnis));
imgzposition = 10;
%surf([min(min(t)) max(max(t))],[min(min(L_input)) max(max(L_input))],repmat(imgzposition, [2 2]),...
%    abs(ergebnis),'facecolor','texture')
%s = surf(t,L_input,ergebnis);
%set(s, 'edgecolor','none')
view(45,45);
xlim([-10 10]);
ylim([0 L_input(end)]);
colormap hot; 
set(gca,'YDir','normal');
cleanfigure('minimumPointsDistance', 10);
matlab2tikz('./LaTeX/final_dispersion.tex', 'floatFormat', '%.2f', ...
        'height', '\figureheight', 'width', '\figurewidth');

MATLAB Figure

But somehow the PGFPlots interpreter is not able to rotate and scale the PNG parts of that graph properly. I used view(45,45) in Matlab for the perspective. As you can see, I tried imagesc() and surf() for creating the colormap. But both functions give the same output in LaTeX. Without rotation PGFPlots returns the right 2D picture. In LaTeX I used the following simple Code for the Import:

 \begin{figure}[h]
    \centering
    \newlength\figureheight
    \newlength\figurewidth
    \setlength\figureheight{0.3\textwidth}
    \setlength\figurewidth{0.8\textwidth}
    \inputencoding{cp1252}
    \input{./final_dispersion.tex}
    \label{fig:Dispersion}
    \inputencoding{latin1}
\end{figure}

But with perspective rotation I got the following result:

enter image description here

Is that an PGFPlots bug, or is it my fault? Someone had an related issue? Thank you very much

  • Welcome to TeX.SX. The current version of PGFPlots is 1.14. Could you first update to the new version and then retry? – Stefan Pinnow Sep 26 '16 at 10:25
  • Thank you, but that doesn't help. It creates the same output – user115056 Sep 26 '16 at 11:24
  • Then please edit your question and provide your code and the picture, so that we can reproduce your problem. – Stefan Pinnow Sep 26 '16 at 11:28
  • I think there is a misunderstanding. Pgfplots uses the image as the plot and puts axes around them. It doesn't do any transformation to the image itself. Just sees an image. You might want to export the data to a file and plot it directly within pgfplots maybe ? – percusse Sep 26 '16 at 12:05
  • Is it realy like this? would be very bad or? Its hard to believe, because some transformation seem to be possible, otherwise setting the limits for png-graphs in latex wouldn't work anymore, right? And the picture above shows that the png is also cropped to fit inside the axis. But rotation is not possible? – user115056 Sep 26 '16 at 12:33

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.