LaTeX forum ⇒ Graphics, Figures & TablesSingle plot missing after eps-to-pdf conversion

Information and discussion about graphics, figures & tables in LaTeX documents.
Posts: 3
Joined: Thu Aug 17, 2017 10:03 pm

Single plot missing after eps-to-pdf conversion

Postby glennib » Thu Aug 17, 2017 10:24 pm


I'm creating an EPS-file from a Matlab figure by using the equivalent of the following Matlab code:
  1. fig = figure;
  2. subplot(2,1,1)
  3. plot(X_data_1, Y_data_1)
  4. grid on
  5. ylabel('label')
  6. title('title')
  7. subplot(2,1,2)
  8. plot(X_data_2,Y_data_2)
  9. grid on
  10. ylabel('label')
  11. xlabel('label')
  13. print(fig, 'fig_name', '-depsc', '-tiff')

Then I'm using
  1. \includegraphics{fig_name.eps}

to show it in my LaTeX document. This creates a fig_name-eps-converted-to.pdf file.

The original fig_name.eps file displays all the plots, I've viewed it in Acrobat, SumatraPDF and Inkscape, which all show all plot lines perfectly fine. However, when I open the pdf file which was generated, only the first plot shows, not the plot in the second subplot. Let me provide the differences:
side-by-side-screenshot.PNG (99.9 KiB) Viewed 254 times

I've uploaded both files + a screenshot of the difference.

One fix was to append the following lines to the Matlab code before the printing:
  1. hold on
  2. plot(5,-20,'sm') % Adds a single point of a magenta colored square to the last plot.

This makes the actual data (data_2) visible in the pdfs, and in my latex document (but not the random data point). So it seems like the last dataplot does not show after conversion.

Does anyone know what's wrong here?

EDIT: I also tried with the codec -depsc2, did not help.
(171.6 KiB) Downloaded 4 times
(16.34 KiB) Downloaded 4 times


Posts: 198
Joined: Thu Dec 04, 2008 4:39 am

Postby mas » Fri Aug 18, 2017 2:56 am

I converted the eps file you included using epstopdf on my linux box. The resulting pdf shows all the plots. When I looked at the pdf files, I noticed these differences:

Your file:
  1. <</Producer(MiKTeX GPL Ghostscript 9.19)

My converted file:
  1. <</Producer(GPL Ghostscript 9.21)

I do not know if the Ghostscript version matters. You can explore that. I am attaching the converted file and a screen shot.
pose.png (47.54 KiB) Viewed 249 times
(21.69 KiB) Downloaded 3 times

OS: Debian/GNU Linux; LaTeX System : TeXLive; Editor : Vim

Posts: 3
Joined: Thu Aug 17, 2017 10:03 pm

Postby glennib » Fri Aug 18, 2017 10:58 am

Thanks for exploring that for me. I forgot to mention my setup. It's Windows 7 with MiKTeX. Maybe there's a bug there.

Not sure if it's possible to use a different Ghostscript conversion tool. I will just add an invisible data point to each plot to hotfix the problem as I'm racing to complete my master's thesis now, but I might investigate more later.

Thanks again for your help.

User avatar
Posts: 76
Joined: Thu Aug 03, 2017 10:54 am
Location: france

Postby thomasb » Sat Aug 19, 2017 1:14 am

If you make time in learning tikzpicture addplot, it might worth the effort :

addplot can be given a text file with data in columns that you could export from Matlab.

Example : \addplot[mark=none] table [x index=0, y index=1]{mydata.txt};
which means :
  • \addplot : the command
  • [mark=none] : no dots
  • table : if your file has more than two data columns (otherwise, file instead)
  • [x index=0, y index=1] : first column is x, and second column is y
  • {mydata.txt}; : your file name.

Example for a two columns file :
\addplot[mark=none] file [skip first]{mydatafilewithtwocolumns.txt};
which means :
  • \addplot : the command
  • [mark=none] : no dots
  • file : if your file has two data columns (otherwise, table instead)
  • skip first : skips the first line (like : Day Temperature)
  • {mydatafilewithtwocolumns.txt}; : your file name.
Grids, axis, labels are a piece of work too.
If you convert your Matlab file in raw data columns, I give an eye...

Posts: 3
Joined: Thu Aug 17, 2017 10:03 pm

Postby glennib » Sun Aug 20, 2017 1:10 pm

I will definitely look into that for later research documents. Great tip, thank you.

Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 9 guests