3

I am having problems with custom labels and its position, especially with negative values in the coordinates. I do not get the position on the right side of the y axis and its height is shifted if the start is negative. Do you have a solution for this?

% !TeX program = xelatex

\documentclass{scrartcl}
\usepackage{pstricks}
\usepackage{pst-plot}
\begin{document}

\begin{pspicture}(-1,-3)(3,2.4)
\psaxes[ylabelPos=right](0,0)(3,3.4)
\rput(2,1){position ok}
\psline[linecolor=red,ylabelPos=right](0,0)(0,-1)(1,-1)
\end{pspicture}
%
\begin{pspicture}(-1,-3)(3,2.4)
\psaxes[yLabels={A,B,C,D},ylabelPos=right](0,0)(3,3.4)
\rput(2,1){position not ok}
\rput(2,0.5){labels on left side}
\psline[linecolor=red](0,0)(0,-1)(1,-1)
\end{pspicture}

\begin{pspicture}(-1,-3)(3,2.4)
\psaxes[ylabelPos=right,Oy=-1](0,-1)(3,2.4)
\psline[linecolor=red](0,0)(0,-1)(1,-1)
\rput(2,1){position ok}
\end{pspicture}
%
\begin{pspicture}(-1,-3)(3,2.4)
\psaxes[yLabels={A,B,C,D},ylabelPos=right](0,-1)(3,2.4)
\psline[linecolor=red](0,0)(0,-1)(1,-1)
\rput(2,1){position not ok}
\rput(2,0.5){labels on left side}
\rput(2,0){and shifted down}
\end{pspicture}

Red Corner for Reference Position 
\end{document}
2
  • It looks like a bug: it you use the default labels, this doesn't happen.
    – Bernard
    Jul 16, 2019 at 13:44
  • The position test for special labels is missing. I'll upload a new version to CTAN at evening.
    – user187802
    Jul 16, 2019 at 15:22

1 Answer 1

2

Will be fixed as soon as possible:

\documentclass{scrartcl}
\usepackage{pstricks}
\usepackage{pst-plot}
\makeatletter\def\pst@vlabels#1#2#3#4{%
  \ifSpecialLabelsDone\else
      \ifx\empty\psk@yLabels
        \ifdim#1=\z@\else
          \ifx#2\empty\else\ifdim#1>\z@ \advance#1 by -7\pslinewidth\else\advance#1 by 7\pslinewidth\fi\fi
          \pst@cnta=#1\relax           %      % Distance (in sp) to end.
          \divide\pst@cnta\psk@dy\relax%   % Number of ticks/labels
          \ifnum\pst@cnta=\z@\else
            \pst@dima=\psk@dy sp%            % Space between ticks.
            \ifodd\number\psk@labels\else\ifPst@yAxis\pst@@vlabels\fi
          \fi
          \showoriginfalse
        \fi
      \fi
    \else
        \pstFPsub\pst@pmtempa{#4}{#3}%
        \pstFPDiv\pst@pmtempb{\pst@pmtempa}{\psk@Dy}%
        \pstFPadd\pst@pmtempc{\pst@pmtempb}{-1}%
        \pstFPadd\pst@pmtempd{\pst@pmtempb}{1}%
        \ifdim\pst@pmtempb pt < \z@ 
        \def\pst@pmtempe{\pst@int{\pst@pmtempc}}\else\def\pst@pmtempe{\pst@int{\pst@pmtempd}}\fi
        \multido{\nA=0+1,\rA=#3+\psk@Dy}{\pst@pmtempe}{%
          \ifdim \nA pt < \z@ \def\nB{-\nA}\else \def\nB{\nA}\fi
          \ifnum\psk@ylabelPos=0
            \uput{\psylabelsep}[180]{\pst@yLabelsRot}(0,\rA){%
              \strut\expandafter\psvlabel\expandafter{\psPutYLabel{\nB}}}%
          \else
            \uput{\psylabelsep}[0]{\pst@yLabelsRot}(0,\rA){%
              \strut\expandafter\psvlabel\expandafter{\psPutYLabel{\nB}}}%
          \fi
        }%  
      \SpecialLabelsDonetrue
    \fi
  \fi
}
\makeatother
\begin{document}

\begin{pspicture}(-1,-3)(3,2.4)
\psaxes[ylabelPos=right](0,0)(3,3.4)
\rput(2,1){position ok}
\psline[linecolor=red,ylabelPos=right](0,0)(0,-1)(1,-1)
\end{pspicture}
%
\begin{pspicture}(-1,-3)(3,2.4)
\psaxes[yLabels={A,B,C,D},ylabelPos=right](0,0)(3,3.4)
\rput(2,1){position not ok}
\rput(2,0.5){labels on left side}
\psline[linecolor=red](0,0)(0,-1)(1,-1)
\end{pspicture}

\begin{pspicture}(-1,-3)(3,2.4)
\psaxes[ylabelPos=right,Oy=-1](0,-1)(3,2.4)
\psline[linecolor=red](0,0)(0,-1)(1,-1)
\rput(2,1){position ok}
\end{pspicture}
%
\begin{pspicture}(-1,-3)(3,2.4)
\psaxes[yLabels={,A,B,C,D},ylabelPos=right](0,-1)(3,2.4)
\psline[linecolor=red](0,0)(0,-1)(1,-1)
\rput(2,1){position not ok}
\rput(2,0.5){labels on left side}
\rput(2,0){and shifted down}
\end{pspicture}

Red Corner for Reference Position 

\begin{pspicture}(-1,-3)(3,2.4)
\psaxes[yLabels={,A,B,C,D}](0,-1)(3,2.4)
\psline[linecolor=red](0,0)(0,-1)(1,-1)
\rput(2,1){position not ok}
\rput(2,0.5){labels on left side}
\rput(2,0){and shifted down}
\end{pspicture}

\end{document}

enter image description here

2
  • In the last axis the label "D" missing. I run the code and removed the first comma. This produces the "A" label shifted one place downwards and the D to be on the penultimate place. But this could be workarounded by a linear shift of the data.
    – Niklas
    Jul 17, 2019 at 19:52
  • the dataset is a replacement for the integers, here -1=A and so on. I used the leading , only just for one. -1=<empty> in this case and D will not be printed.
    – user187802
    Jul 18, 2019 at 4:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .