Add text to PDF - matlab

I've got an exported version of a MATLAB diagram, similar to the one below. The problem is, that there are no axis captions. It's not possible to export the file again from MATLAB. I need to edit the PDF programmatically and edit about 100 diagrams, all with the same axis positions.
Is there a clean and fast way to paste the Strings X and Y at the corresponding positions in the pdf based on a batch process?

Create a PDF file with the captions. Add that as a background with to the PDF files with pdftk.

if know how to use LaTeX, the pstool package can bring you far on this on, including replacing labels (or actually any text on an eps figure) with TeX symbolic expressions. Neat if you're already working in LaTeX.

Related

Is EPS image editable

I converted a matlab fig to eps, I need to add the grid to this figure which now I have in eps format. Is there any possibility. I know I can change the title or labels using ultraedit or similar programs but cant identify the relevant place for grid.
Yes, you simply need to read the PostScript program and then modify it to be suitable for your needs.
You will, however, probably need a working knowledge of the PostScript language in order to understand the program and succesfully modify it.

Insert vector graphics from Matlab to Word 2013

i know its a often discussed topic. But i haven't found any solution for me. I have some plots, which i need to import in Word 2013 afterwards the docx is saved as pdf.
The problem is:
If the plot gets saved (with the function print() ) as .eps or emf and imported in Word, the downsampled placeholder of the graphics look pretty poor and the graphics in pdf are no vector grapic anymore. They do get turned into a bitmap and by zooming in a bit, one can see the pixels. If i use Edit -> Copy Figure in the Matlab figure and paste it in Word, i get a nice graphic in Word as well as a nice vector based graphic in the pdf file.
Is there a way, to save a figure to a file and import it to Word and have the same quality like i have by copy and paste? What is the difference between these methods?
Thank you for your help.
Rafael

Differences between these two methods to include Matlab figures in a Powerpoint presentation

I want to include Matlab figures in a Powerpoint presentation. [Note that in other contexts, I usually use LaTeX beamer with .eps files, but here I am obliged to use Powerpoint.]
I know two ways:
Save the image as e.g. a .tiff file and include the image in Powerpoint. The result does not always look sharp and some lines are too thin.
Copy the image directly in Matlab and paste it in Powerpoint. The resulting figure is way nicer. But after exporting the Powerpoint to pdf, it may take some time to load the figure (especially when you included grid minor).
What is the difference between these two methods: is it the well-known bitmap vs. vector image difference or something else? Is there a way to have the quality of the second method but without the problem that is loads slowly?

Matlab figure saved as .eps appears in 'horizontal sections' when opened in Adobe Illustrator

I normally save my matlab figures as .eps and then make them better looking using Adobe Illustrator. This works for most figures but not all.
For example I plotted my data using the violin.m function from file exchange. When I save it as .eps and open it in Illustrator, I don't get an editable figure as I usually do. Instead, My figure appears chopped in horizontal sections, and all I can do is delete them (like in the figure below).
Is there anything I can do in either matlab or Illustrator to be able to edit the figure?
I don't need an .eps file, I just need to be able to edit it.
EDITS:
I tried #MattSchmatt's suggestion of using the print2eps function but I had the same problem.
Saving as .pdf doesn't solve the problem, because the image I get is not editable in Illustrator (plus, I also get the horizontal 'chunks').
A minimal, complete and verifiable example requires matlab, the violin function linked above and illustrator. But if it helps, here's the matlab code to produce a similar figure. I save by clicking on Figure -> save as. (But as I said above I tried the print2eps function and that was the same).
X = rand(100,6);
figure; violin(X)
I tried the following, didn't work either.
set(gcf, 'Renderer', 'painters')
As the author of the question suggests, I also wasn't able to export an editable (vectorized) .eps file into Illustrator. However, exporting it as .pdf does the trick. The 'fill' for the violin plots is weird, though, and has horizontal sections (perhaps something to do with the way the density estimate is being plotted?) all over. I was able to fix this and make the plots normal (with solid filled shades): select all the horizontal sections/chunks using the magic wand tool, and then increase opacity to 100% (it is set to 50 based on the exported file). Once all the required edits are made, export the file as .tiff and it seems to look fine. Hope this replicates, and thus helps! (my MATLAB version is 2016, and Illustrator version is the CS5)

Is it possible to get around MATLAB's limitation on font embedding in vector format files?

According to the MATLAB manual, when you save a figure using print or by choosing file|save, if you choose the painters renderer and save to PDF or EPS vector formats, all fonts get substituted. Is there a way to get around this limitation?
Whenever I output a figure, whether I use print or export_fig, the fonts get substituted, and so they no longer match the fonts in the document that I plan on putting the figure into. I would prefer to keep them in a vector format, because I use LaTeX and so I want to be able to use the same figures in my documents as in my beamer presentations and have them scale nicely without bloating the file size.
If I'm reading that link correctly, not all fonts get substituted. From 'Choosing a Printer Driver':
The table below lists the fonts supported by the MATLAB PostScript and Ghostscript drivers when generated with the Painters renderer (fully vectorized output). This same set of fonts is supported on both Windows and UNIX:
AvantGarde
Helvetica-Narrow
Times-Roman
Bookman
NewCenturySchlbk
ZapfChancery
Courier
Palatino
ZapfDingbats
Helvetica
Symbol
So, if you use one of the above fonts, the output vector-format figure should maintain the correct font. See for example:
list_fonts = listfonts
figure('renderer','painters'),
plot(peaks),
xlabel('this font is Helvetica','fontname','Helvetica','fontsize',24)
set(gcf,'paperpositionmode','auto')
print(gcf,'-depsc2','test1.eps')
Which produces:
So, choose one of the fonts from the list above, and the font will be output correctly. Otherwise, change the font in your presentation to match one of the above fonts.
I also encountered this problem for many times, and I have an simple but effective way that never fails me (on Windows, need GSview).
1) save fig as PDF
2) save PDF as ps
3) open ps with GSview, then click "File->PS to EPS", specify a file name and done.
Hope this helps.