# Drawing a complex transformation using PStricks

I'm trying to draw the picture below showing a typical instance of mapping the z point from z plane to w plane by the f(z) transformation.

It is almost OK, but when I'm trying to draw the dashed lines I face problems and they are not fixed at my wish points.

I have made many changes regarding the axes. I defined a third Cartezian coordinate system for dashed lines, drawing it on the first and second one, changed it's coordinates to many other coordinates, but nothing has been changed. I've also checked the tug.org examples.

It's all OK when I'm using the straight lines but drawing the dashed curve causes a problem when I do make this change.

The code which I'm using is:

\documentclass{article}

\usepackage{pstricks}
\usepackage{pst-plot}

\begin{document}

‎\psset{xunit=.5cm‎, ‎yunit=.5cm}‎
‎\begin{pspicture}(0,0)(17,5)‎
‎\psaxes[labels=none‎ , ‎ticks=none]{->}(0,0)(5,5)‎
‎\rput(0,5.2){y}‎
‎\rput(5.2,0){x}‎
‎\rput(3,2.3){c}‎
‎\psbezier[linecolor=blue]{-}(1,1)(3,2)(4,1)(5,3)‎
‎\psbezier[linestyle=dashed]‎{-}(‎3‎,3)(‎6‎,4)(10,2) %the line which cause me problems‎
‎\psdot(1,1)‎
‎\rput(1,0.5){$p_{1}$}‎
‎\psdot(5,3)‎
‎\rput(5,2.3){$p_2$}‎
‎\psaxes[labels=none‎ , ‎ticks=none]{->}(12,0)(17,5)‎
‎\psbezier[linecolor=blue]{-}(13,1)(15,2)(16,1)(17,3)‎
‎\end{pspicture}‎

\end{document}


and the output of this code is the below picture where the dashed line is not placed at the appropriate coordinates.

So what should I exactly change in order to gain the right output?

-
It's always nice if you provide a complete, compilable example, an MWE, that makes it easier for those trying to help. –  Torbjørn T. Nov 3 '11 at 14:50
excuse me , but I don't get it , what should I exactly do ? is the example which I've made not compilable or incomplete ? or should I ask it somewhere else? –  Negin Nov 4 '11 at 15:00
Your example wasn't directly compilable, as there was no preamble with a documentclass and the necessary packages, and a document environment. Werner fixed that for you though. –  Torbjørn T. Nov 4 '11 at 15:05
OK , thank you very much I'll consider it in my future posts –  Negin Nov 4 '11 at 15:30

I used the \psgrid command to help guide where I wanted to put the points on the connecting \psbezier curve- you can tweak them to whatever you would like.

\documentclass{article}

\usepackage{pst-plot}

\begin{document}

\psset{xunit=.5cm, yunit=.5cm}
\begin{pspicture}(0,0)(17,5)
% \psgrid % very useful during construction
\psaxes[labels=none,ticks=none]{->}(0,0)(5,5)[$x$,0][$y$,90]
\rput(3,2.3){c}
\psbezier[linecolor=blue]{-}(1,1)(3,2)(4,1)(5,3)
\psbezier[linestyle=dashed]{-}(3,4)(8,5)(9,5)(14,4) %the line which cause me problems‎
\psdot(1,1)
\uput[-90](1,1){$p_1$}
\psdot(5,3)
\uput[-45](5,3){$p_2$}
\psaxes[labels=none , ticks=none]{->}(12,0)(17,5)
\psbezier[linecolor=blue]{-}(13,1)(15,2)(16,1)(17,3)
\end{pspicture}

\end{document}


Note that I changed a few pieces of your code to remove some of the \rput. In particular, I used

\psaxes[labels=none,ticks=none]{->}(0,0)(5,5)[$x$,0][$y$,90]


which puts the axis labels on for you- the 0 and 90 are angles in relation to the default position.

I also used

\uput[-90](1,1){$p_1$}
...
\uput[-45](5,3){$p_2$}


to attach $p_1$ and $p_2$ to the relevant points; again, the -90 and -45 are angles in relation to the original point. This saves the guesswork involved with \rput.

Here's my attempt at creating the completed original picture

\documentclass{article}

\usepackage{pst-plot}

\begin{document}

\psset{xunit=.5cm, yunit=.5cm}
\begin{pspicture}(-1,-1)(18,6)
%\psgrid % very useful during construction
% 1st plot
\psaxes[labels=none,ticks=none]{->}(0,0)(-1,-1)(5,5)[$x$,0][$y$,90]
\psbezier[linecolor=blue]{-}(1,2)(2,5)(4,1)(5,2)
\psdots(1,2)(5,2)
\uput[-90](1,2){$p_1$}
\uput[-45](5,2){$p_2$}
\uput[45](2,3){$c$}
% 2nd plot
\psaxes[labels=none,ticks=none]{->}(12,0)(11,-1)(17,5)[$x$,0][$y$,90]
\psbezier[linecolor=blue]{-}(11,2)(13,4)(14,3)(15,3)
\psdots(11,2)(15,3)
\uput[-90](11,2){$p_1'$}
\uput[-45](15,3){$p_2'$}
\uput[0](13,4){$c'$}
% connecting curve
\psbezier[linestyle=dashed]{->}(5,3)(8,4)(8,4)(11,3)
\uput[90](8,4){$w=f(z)$}
\end{pspicture}

\end{document}


Following @Werner's comment, here's another solution, but it uses pst-node. This is the most robust of the solutions I have presented.

\documentclass{article}

\usepackage{pst-plot}
\usepackage{pst-node}

\begin{document}

\psset{xunit=.5cm, yunit=.5cm}

\begin{pspicture}(-1,-1)(18,6)
%\psgrid % very useful during construction
% 1st plot
\psaxes[labels=none,ticks=none]{->}(0,0)(-1,-1)(5,5)[$x$,0][$y$,90]
% p1
\pnode(1,2){p1}\uput[-90](p1){$p_1$}
% p2
\pnode(5,2){p2}\uput[-45](p2){$p_2$}
\psdots(p1)(p2)
% connect p1 and p2
\nccurve[angleA=80,angleB=210,linecolor=blue]{p1}{p2}
\naput{$c$}
% 2nd plot
\psaxes[labels=none,ticks=none]{->}(12,0)(11,-1)(17,5)[$x$,0][$y$,90]
% p1'
\pnode(11,2){p1p}\uput[-90](p1p){$p_1'$}
% p2'
\pnode(15,3){p2p}\uput[-45](p2p){$p_2'$}
\psdots(p1p)(p2p)
% connect p1' and p2;
\ncarc[arcangle=45,linecolor=blue]{p1p}{p2p}
\naput[npos=0.7]{$c'$}
% w=f(z), connecting line
\pnode(5,3){w1}
\pnode(11,3){w2}
\ncarc[arcangle=45,linestyle=dashed,arrows=->]{w1}{w2}
\naput{$w=f(z)$}
\end{pspicture}

\end{document}

-
Just a suggestion: I would use an arc (like \psarc or \pcarc) for the dashed line linking the two subfigures. It may just be personal preference, but the \psbezier seems to have a marginal cusp in the middle and I think an arc would be smoother. Also, using pst-node helps code readability by naming nodes. –  Werner Nov 3 '11 at 17:14
@Werner: Yes, I totally agree with both of your suggestions :) I have presented a pst-node option, let me know if you have any other improvements :) –  cmhughes Nov 3 '11 at 18:18
it makes no real sense to define two nodes and then doing nothing else than drawing a curve. \pcarc is also available which takes pairs of coordinates and/or nodes –  Herbert Nov 3 '11 at 19:03
@Herbert: I agree. But perhaps the approach here is more general (albeit somewhat superfluous in this MWE). That is, if there is a larger graphic with more "points of interest," using nodes improves code readability and ease-of-reference. –  Werner Nov 3 '11 at 19:06
@cmhughes: sure. the most important fact is to have a nice graphic and, of course, only the second one is to have a nice code ... :-) –  Herbert Nov 3 '11 at 19:14
show 1 more comment
\documentclass{article}
\usepackage{pst-plot,pst-node}
\begin{document}

%‎\psset{unit=.5cm‎}‎
‎\begin{pspicture}(6.5,5)‎
‎\psaxes[labels=none‎, ticks=none]{->}(5,5)[$x$,0][$y$,90]‎
‎\rput(3,2){c}‎
‎\psbezier[linecolor=blue,linewidth=1pt](1,1)(3,2)(4,1)(5,3)‎
\pnode(4,3){Left}
\end{pspicture}‎
%
‎\begin{pspicture}(5.5,5)‎
‎‎\rput(1,0.5){$p_{1}$}‎  ‎\rput(5,2.3){$p_2$}‎
‎\psaxes[labels=none‎,ticks=none]{->}(5,5)[$x$,0][$y$,90]‎‎
‎\psbezier[linecolor=blue,linewidth=1pt]{*-*}(1,1)(3,2)(4,1)(5,3)‎
‎\pccurve[linestyle=dashed,angleA=30,angleB=150,
arrowscale=2]{->}(Left)(1,3)\naput{$w=f(z)$}
‎\end{pspicture}‎

\end{document}


-