[Tex/LaTex] Redefining axes label in pst-plot

labelspst-plotpstricks

I am trying to redefine the labels for x-axis in a pst-plot diagram by putting

\makeatletter
\def\ps@@@hlabel#1{\small(#1)}
\makeatother

in the preamble (see top of page 25 in the manual) but then no labels are printed at all.

Example:

\documentclass{article}

\usepackage{pst-plot}

% Label redefinition. (NOT working)
\makeatletter
\def\ps@@@hlabel#1{\small(#1)}
\makeatother

% Makes things easier.
\def\afspil#1#2{%
%  \rput(!2 #1 mul -0.3){\small{(#1)}}  <--  (`manually' plotting of labels)
  \psline[linecolor=red](!2 #1 mul 0)(!2 #1 mul #2)
  \psline[linecolor=red](!2 #1 mul 0.2 sub #2)(!2 #1 mul 0.2 add #2)
}

\begin{document}

\begin{pspicture}
  \psaxes[
    labels=none,
    ticks=y,
    ticklinestyle=dotted,
    tickwidth=0.5pt,
    yticksize=0 12.9
  ]{->}(0,0)(-0.3,-0.3)(13.1,8.6)[Sang,0][Afspilninger,90]
  \psaxes[
    dy=1,
    Dy=10,
    labels=y,
    ticks=y,
    ylabelFactor=\cdot 10^3
  ](0,0)(-0.3,-0.3)(13.1,8.6)
  \afspil{1}{6.4098}
  \afspil{2}{5.0320}
  \afspil{3}{7.5437}
  \afspil{4}{6.3253}
  \afspil{5}{0.5735}
  \afspil{6}{6.9024}
\end{pspicture}

\end{document}

How do I redefine the labels on the x-axis?

Best Answer

There are two things: first you draw two axes with only y-labels, and the macro, which you need to change is \pst@@@hlabel. It is correct in the text of page 25, but wrong in the example following the paragraph. The following works:

\documentclass{article}

\usepackage{pst-plot}

% Label redefinition.
\makeatletter
\def\pst@@@hlabel#1{\small(#1)}
\makeatother

% Makes things easier.
\def\afspil#1#2{%
%  \rput(!2 #1 mul -0.3){\small{(#1)}}  <--  (`manually' plotting of labels)
  \psline[linecolor=red](!2 #1 mul 0)(!2 #1 mul #2)
  \psline[linecolor=red](!2 #1 mul 0.2 sub #2)(!2 #1 mul 0.2 add #2)
}

\begin{document}

\begin{pspicture}
  \psaxes[
    labels=none,
    ticks=y,
    ticklinestyle=dotted,
    tickwidth=0.5pt,
    yticksize=0 12.9
  ]{->}(0,0)(-0.3,-0.3)(13.1,8.6)[Sang,0][Afspilninger,90]
  \psaxes[
    dy=1,
    Dy=10,
    ylabelFactor=\cdot 10^3
  ](0,0)(-0.3,-0.3)(13.1,8.6)
  \afspil{1}{6.4098}
  \afspil{2}{5.0320}
  \afspil{3}{7.5437}
  \afspil{4}{6.3253}
  \afspil{5}{0.5735}
  \afspil{6}{6.9024}
\end{pspicture}

\end{document}
Related Question