[pstricks] framing overlapping objects

Matthias Thomae bluez at thomae-privat.de
Tue Aug 17 16:43:40 CEST 2004


Hello pstricks users,

I'd like to draw 2 graphics objects (say, a pstricks plot and a legend), 
and overlap these to varying degrees, depending on the contents of the 
plot. More precisely, I know the position of the topmost data point so 
that I can shift the legend onto the plot, to save space.

   ----------
--| legend |--
| ---------- |
|       x    |
|      x     |
|    xx      |
|   x        |
--------------

I tried to solve the problem by putting the legend and the plot in two 
rows of a psmatrix, and specify a negative row separation.

However, because I don't know (how to calculate) the size of the legend 
(it's text in a table or a psmatrix), I don't know if the legend is 
fully contained in the plot or protrudes at the top.

If it is not, the 2nd matrix row (the plot) is above the 1st row (the 
legend), which causes the surrounding text to also overlap the plot, 
which is not intended.

Does anyone know a solution for this, maybe using something different 
than a psmatrix, or how to get the psmatrix to calculate its borders 
'correctly' in such a case?

I've also appended a small sample script to demonstrate the problem.

Regards.
Matthias

--------------------------------------------

\documentclass{article}
\usepackage{pstricks,pst-all}

\def\mydata{
   0 0
   3 1
   5 2.5
}

\def\legend{
   \psframebox{
     \begin{psmatrix}[rowsep=0.0cm]
       \bf legend \psspan{2} \\
       par 1 & val 1 \\[0.0cm]
       par 2 & val 2
     \end{psmatrix}
   }
}

\begin{document}

text above

\psframebox{
   \begin{psmatrix}[rowsep=-2.5cm]
     \legend
     \\
     \begin{pspicture}(-1,-1)(5,5)
       \psaxes(0,0)(5,5)
       \listplot[plotstyle=line,showpoints=true]{\mydata}
     \end{pspicture}
   \end{psmatrix}
}

text below

\end{document}




More information about the PSTricks mailing list