Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

As you see the image below, the label "4" on y-axis gets in the way with the plot. How do I move it to the right? I tried adding the following statement:

psyTick[ylabelPos=right](4){4}

But doesn't work.

enter image description here

Here is the whole code:

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}

\begin{document}

\psset{xunit=2,
       yunit=0.5,
       linewidth=0.03,
       tickwidth=0.03}

\begin{pspicture}(-1.775,-2)(1.775,6.8)
\psaxes[Dx=1,labels=x,xticksize=-4pt,Dy=2]{->}(0,0)(-1.77,0)(1.7,6.4)[$t$,0][$$,90]
\psyTick[ylabelPos=left](2){2}
\psyTick[ylabelPos=right](4){4}
\psline[linecolor=blue,linewidth=0.05](-1.7,0)(-1,0)(-1,4)(0,4)(0,2)(1,2)(1,0)(1.6,0)
\rput(-0.6,4.5){$x_1(-2(t-1))$}
\end{pspicture}

\end{document}
share|improve this question

2 Answers 2

up vote 3 down vote accepted

You have to adjust the way \psyTick works since it currently doesn't support the placement:

enter image description here

\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}

\makeatletter
\def\psyTick@ii#1(#2)#3{{
  \pst@killglue
  \addbefore@par{arrows=-,linewidth=\psk@ytickwidth\pslinewidth}
  \use@par
  \psline(\pst@yticksizeB,#2)(\pst@yticksizeA,#2)
  \expandafter\ifx\psk@ylabelPos\tw@ %      2=right
    \rput[l]{#1}(! \psk@origin
                    \pst@number\pst@yticksizeB \pst@number\psylabelsep add
                    \pst@number\psxunit div #2){\psvlabel{#3}}\ignorespaces
  \else
    \expandafter\ifx\psk@ylabelPos\@ne %    1=axis
      \rput{#1}(! \psk@origin
                      0 #2){\psvlabel{#3}}\ignorespaces
    \else % \psk@ylabelPos=\z@ 0=left
      \rput[r]{#1}(! \psk@origin
                      \pst@number\pst@yticksizeB \pst@number\psylabelsep add
                      \pst@number\psxunit div neg #2){\psvlabel{#3}}\ignorespaces
  \fi\fi}}
\makeatother

\begin{document}

\psset{xunit=2,
       yunit=0.5,
       linewidth=0.03,
       tickwidth=0.03}

\begin{pspicture}(-1.775,-2)(1.775,6.8)
  \psaxes[Dx=1,labels=x,xticksize=-4pt,Dy=2]{->}(0,0)(-1.77,0)(1.7,6.4)[$t$,0][$$,90]
  \psyTick[ylabelPos=l](2){2}
  \psyTick[ylabelPos=a](3){3}
  \psyTick[ylabelPos=r](4){4}
  \psline[linecolor=blue,linewidth=0.05](-1.7,0)(-1,0)(-1,4)(0,4)(0,2)(1,2)(1,0)(1.6,0)
  \rput(-0.6,4.5){$x_1(-2(t-1))$}
\end{pspicture}

\end{document}

Instead of a fixed/single \rput, it's been adjusted to condition on the value of \psk@ylabelPos to decide whether the place the label on the left (\z@), right (\tw@) or on the axis (\@ne).

share|improve this answer
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{pst-plot}
\begin{document}

\psset{xunit=2,yunit=0.5,linewidth=0.03,tickwidth=0.03}
\begin{pspicture}(-1.775,-2)(1.775,6.8)
  \psaxes[Dx=1,labels=x,xticksize=-4pt,Dy=2]{->}(0,0)(-1.77,0)(1.7,6.4)[$t$,0][,90]
  \uput[180](0,2){2}  \uput[0](0,4){4}
  \psline[linecolor=blue,linewidth=0.05](-1.7,0)(-1,0)(-1,4)(0,4)(0,2)(1,2)(1,0)(1.6,0)
  \rput(-0.6,4.5){$x_1(-2(t-1))$}
\end{pspicture}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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