2

Assume someone has several Matlab plots saved as .eps graphics and realizes in some of them the legend for the curves is missing.
Is there a way to add these legends afterwards, or to overlay another .eps graphic that contains just the legend box? The .eps graphics are included like

\begin{figure}[htb]
    \centering
    \includegraphics[width=0.7\textwidth]{path/to/eps}
    \cprotect\caption{gibberish.}
    \label{fig:fug}
\end{figure}

A solution using as little 'non-standard' libraries as possible would be favored.

1

With PSTricks.

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{graphicx}

\def\filename{fist-of-legend}
\def\row{10}
\def\column{10}
\def\scale{1}


\newsavebox\IBox
\savebox\IBox{\includegraphics[scale=\scale]{\filename}}
\psset
{
    xunit=\dimexpr\wd\IBox/\column,
    yunit=\dimexpr\ht\IBox/\row,
}

\begin{document}
\begin{pspicture}[showgrid=top](\column,\row)% set showgrid=false for the final
    \rput[bl](0,0){\usebox\IBox}
    \rput(7,1.25){\psscalebox{3}{\bf\color{white}PSTricks}}
\end{pspicture}
\end{document}

Remarks:

  1. Compile it with either latex-dvips-ps2pdf sequence (much faster) or xelatex (much slower).
  2. Toggle the showgrid with true, false, top, or bottom. true is identical to bottom. The grid is useful to find the coordinate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.