2

When labeling an axis, it is possible to replace the labels with (for instance for y-axis) yLabels={<label-pattern>}. If I understand well, the given labels replace the otherwise numeric labels starting from the origin of the axis, replacing successive labels going in the positive direction (increasing numeric labels). Thus, it is not possible to replace a numeric label below the origin. Is there a way to change the behavior, so that the label replacement starts at the smallest numeric label, in such a way that the following would work (a replaces -1, b replaces 0, c replaces 1)?

\documentclass{article}
\usepackage{pstricks,pst-plot}
\begin{document}
\begin{pspicture}
\psaxes[yLabels={a,b,c}](0,0)(0,-1)(1,1)
\end{pspicture}
\end{document}

I mention that different versions of pstricks seem to give different results, but the latest version (shipped in texlive-pstricks-2016.42276-1 under archlinux) outputs weird behavior with the above.

3 Answers 3

2

With the latest version pf pst-plot.tex (1.76) from http://comedy.dante.de/~herbert/texnik/tex/generic/pst-plot/

\documentclass{article}
\usepackage{pstricks,pst-plot}
\begin{document}
\begin{pspicture}(-0.5,-1.5)(1.5,1.5)
\psaxes[showorigin=false,yLabels={a,b,c}](0,0)(0,-1)(1,1)
\end{pspicture}
\begin{pspicture}(-0.5,-0.5)(1.5,2.5)
\psaxes[showorigin=false,yLabels={a,b,c}](1,2)
\end{pspicture}
\begin{pspicture}(-0.5,-2.5)(1.5,.5)
\psaxes[showorigin=false,yLabels={a,b,c}](0,0)(0,-2)(1,0)
\end{pspicture}
\end{document}

enter image description here

1
  • Thanks for such reactivity! Now it works exactly as I intended. (let me mention that for some reason I get an error about \pstScalePoints not being defined, due to the line right after its definition (!) in the provided pst-plot.tex) Commented Jan 18, 2017 at 12:29
1

Here is a workaround: it consists in plotting twice, with negative values for dy and yunit:

\documentclass{article}
\usepackage{pst-plot, auto-pst-pdf}%

\begin{document}

\begin{pspicture}
\psaxes[yLabels={,a, b,}](0,0)(- 1,0)(1,2)%s
\psset{dy = -1, yunit = -1}%,
\psaxes[yLabels={,c,d}, linecolor = red](0,0)(0,0)(0,2.05)
\end{pspicture}

\end{document} 

enter image description here

0

After reading the workaround of Bernard, I write here a similar but more elegant way to achieve what I described in my original post. The idea is symply to shift the labeling of the amount of the smallest numeric label. This requires to treat the other axis separately (and using showorigin=false to avoid overlap of the second axis with the origin label of the first one).

\documentclass{article}
\usepackage{pstricks,pst-plot}
\begin{document}
\begin{pspicture}
% \psaxes[yLabels={a,b,c}](0,0)(0,-1)(1,1) % would not work
\psaxes[showorigin=false](0,0)(1,0) % x-axis only, 0 y-width
\psaxes[yLabels={a,b,c}](0,-1)(0,1) % y-axis only, 0 x-width
\end{pspicture}
\end{document}

enter image description here

However, such workaround is not completely satisfactory because if I decide to go for the numeric labels instead with yLabels={} (as I would provide an empty argument in a macro for instance), then the labels are not correct (since they are shifted!). I would accept my own answer if nobody knows how to avoid that (maybe changing the yLabels option internally in pst-plot?)

1
  • see my answer for a modified pst-plot
    – user2478
    Commented Jan 18, 2017 at 11:36

You must log in to answer this question.

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