Graphics, Figures & TablesAdd arrows to Matlab generated EPS?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Add arrows to Matlab generated EPS?

Post by stinkinrich88 »

Hello,

I made a plot using Matlab and exported it using laprint.m so that psfrag will replace the matlab text with LaTeX text.

I now need to add some arrows to the plot, but I can't figure out how to.

I used Inkscape to add the arrows, but when I save it (still as an esp) psfrag no longer replaces the text. I think this is because Inkscape uses Cario to export the esp, but I'm not sure.

How can I do this? Perhaps I can save the arrows in a separate esp file and overlay it?

Thanks,

Rich

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Add arrows to Matlab generated EPS?

Post by gmedina »

Hi,

perhaps the overpic package could be useful for you.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Add arrows to Matlab generated EPS?

Post by localghost »

Just for the record. The file format you mean is called EPS (Encapsulated PostScript), This might not appear important for you. But the search function would fail if somebody searches for EPS related problems. Therefore the title of the thread has been conformed.


Best regards
Thorsten
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Add arrows to Matlab generated EPS?

Post by stinkinrich88 »

Hi, sorry about the EPS error!

Thanks for recommending Overpic. It seems to do what I require, however, I cannot work out how to match the size/positions. I thought it would be simple as both images have the same papersize and are perfectly positioned for eachother, but when I use the following code, the arrow overlay is far too big:

Code: Select all

\begin{overpic}[width=0.6\columnwidth]{RandomWaypoint.eps}%
	\put(0,0){\includegraphics[width=0.6\columnwidth]{Arrows.eps}}%
\end{overpic}
Thanks
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Re: Add arrows to Matlab generated EPS?

Post by gmedina »

If it is possible for you to attach both images to your next post, then we could do some tests and make a suggestion.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Add arrows to Matlab generated EPS?

Post by stinkinrich88 »

Certainly. It would not let me upload eps files to this site, so I have hosted them here:

http://users.cs.cf.ac.uk/R.P.Coombs/bucket/Arrows.eps
http://users.cs.cf.ac.uk/R.P.Coombs/buc ... ypoint.eps

I have also attached the file used to insert the images (and use psfrag), so to display the images you should only need this code:

Code: Select all

\begin{figure}
	\begin{center}
		\import{RandomWaypoint.tex}
	\end{center}
\end{figure}
And psfrag, grapihicsx, overpic in the preamble.

Thanks!
Attachments
RandomWaypoint.tex
This is the file which includes the images (using overpic) and has the psfrag stuff.
(1.55 KiB) Downloaded 346 times
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Add arrows to Matlab generated EPS?

Post by localghost »

stinkinrich88 wrote:[...] It would not let me upload eps files to this site [...]
You can put them into a ZIP or RAR archive. I will contact the administrator and ask him to extend the list of allowed file types.
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Re: Add arrows to Matlab generated EPS?

Post by stinkinrich88 »

Ok, thanks. I've attached a zip archive containing all three files.
Attachments
RandomWaypoint.zip
(6.39 KiB) Downloaded 260 times
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Add arrows to Matlab generated EPS?

Post by gmedina »

The bounding box for Arrows.eps is 50 50 193 216. Change the last part of RandomWaypoint.tex to

Code: Select all

% Figure:
\begin{overpic}{RandomWaypoint.eps}%
	\put(50,50){\includegraphics{Arrows.eps}}%
\end{overpic}
\end{psfrags}%
In your .tex document, use the abs option for the overpic package and use the \scalebox command to scale the figure, as the following example suggests:

Code: Select all

\documentclass{report}
\usepackage{graphicx,xcolor,psfrag}
\usepackage[abs]{overpic}

\begin{document}
\begin{figure}[!ht]
 \centering
 \scalebox{.6}{\input{RandomWaypoint.tex}}
\end{figure}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
stinkinrich88
Posts: 52
Joined: Sat Jun 07, 2008 11:56 am

Re: Add arrows to Matlab generated EPS?

Post by stinkinrich88 »

Oh that's perfect! Thanks very much :-)
Post Reply