## LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Single plot missing after eps-to-pdf conversion

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

### Single plot missing after eps-to-pdf conversion

Hello,

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')
12.
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 754 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.
Attachments
pose.eps
pose-eps-converted-to.pdf

Tags:

mas
Posts: 206
Joined: Thu Dec 04, 2008 4:39 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:

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 749 times
Attachments
pose.pdf

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

glennib
Posts: 3
Joined: Thu Aug 17, 2017 10:03 pm
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.

thomasb
Posts: 76
Joined: Thu Aug 03, 2017 10:54 am
If you make time in learning tikzpicture addplot, it might worth the effort : http://pgfplots.sourceforge.net/gallery.html

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 :
• [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 :
which means :
• [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...

glennib
Posts: 3
Joined: Thu Aug 17, 2017 10:03 pm
I will definitely look into that for later research documents. Great tip, thank you.