[pstricks] Two plots with common axis in one subfigure
Michael Sharpe
msharpe at ucsd.edu
Mon Apr 20 20:15:40 CEST 2009
On Apr 20, 2009, at 8:54 AM, Joel J. Adamson <adamsonj at email.unc.edu>
wrote:
> Dear PSTricks,
>
> I am trying to design a figure that has two panels, one with two
> graphs
> with a common set of axes (one is a population age-distribution, and
> the
> other is a plot of some functions of age). The other panel is a
> distribution (using pst-func), but does not require common axes with
> the
> other two.
>
>
>
> Panel b:
>
> \begin{figure}
> \centering\caption{Example Gaussian Curves}\label{fig:gaussian}
> \psset{yunit=10cm,xunit=2}
> \begin{pspicture}(0,0)(1,1)
> \psaxes[labels = none, ticks = none](5,0.5)
> \psGauss[mue=1, sigma=1]{0}{5}
> \psGauss[linecolor = blue, mue = 2, sigma = 1]{0}{5}
> \end{pspicture}
> \end{figure}
>
> My attempt at panel a (but the figures don't line up):
>
> \begin{figure}
> \centering\caption{More Example lines}\label{fig:lines}
> \begin{pspicture}(0,0)(6,6)
> \psset{yunit=2cm,xunit=1}
> \psaxes[labels = none, ticks = none](6,2)
> \rput(0.5,-0.5){$\alpha_1$}
> \psline{-}(1.5,0)(6,1)
> \rput(2.5,-0.5){$\alpha_2$}
> \psline{-}(3.5,0)(6,2)
> \end{pspicture}
> % \end{figure}
>
> % \begin{figure}
> % \centering\caption{Example bar chart}\label{fig:bar}
> % \psset{yunit=2cm,xunit=1}
> \begin{pspicture}(0,0)(5,1)
> \readpsbardata{\mydata}{data.txt}
> \psbarchart[chartstyle = cluster,
> barcolsep = 0,
> barsep = 0,
> barstyle = {gray,gray,gray,gray,gray,gray},
> showpoints = false]{\mydata}
> \psaxes[labels = none, ticks = none](6,0.65)
> \end{pspicture}
> \end{figure}
>
> What's the best way to line up the two figures in panel a?
>
If you use \psframebox around each pspicture, you can see how the
bounding boxes are aligned. (See code below.) In your example, they
have different horizontal sizes. If you want them vertically aligned,
make the pspicture widths the same. If you want to have the labels on
the top picture not run into the picture below, decrease the top
pspicture ymin value.
Michael
\psset{framesep=0pt}
\begin{figure}
\centering\caption{More Example lines}\label{fig:lines}
\psframebox[linecolor=blue]{%
\begin{pspicture}(0,0)(6,6)
\psset{yunit=2cm,xunit=1}
\psaxes[labels = none, ticks = none](6,2)
\rput(0.5,-0.5){$\alpha_1$}
\psline{-}(1.5,0)(6,1)
\rput(2.5,-0.5){$\alpha_2$}
\psline{-}(3.5,0)(6,2)
\end{pspicture}
}% \end{figure}
% \begin{figure}
% \centering\caption{Example bar chart}\label{fig:bar}
% \psset{yunit=2cm,xunit=1}
\psframebox[linecolor=blue]{%
\begin{pspicture}(0,0)(5,1)
%\readpsbardata{\mydata}{data.txt}
%\psbarchart[chartstyle = cluster,
%barcolsep = 0,
%barsep = 0,
%barstyle = {gray,gray,gray,gray,gray,gray},
%showpoints = false]{\mydata}
\psaxes[labels = none, ticks = none](6,0.65)
\end{pspicture}}
\end{figure}
More information about the PSTricks
mailing list