6

Consider the following example:

\documentclass{article}

\usepackage{pst-plot}

\begin{document}

\psset{xunit = 2}
\begin{pspicture}(3,1)
\psaxes[Dx = 0.5]{->}(3,1)
\end{pspicture}

\end{document}

output

Is it possible to get 1 and 2 instead of 1.0 and 2.0 (as with 0) as axis labels?

Update

I've also asked this question on LaTeX Community (and now added Marco's answer).

7
  • If you make a question in LaTeX-Community then you should not repost it in TeX.StackExchange, or vice verse because cross-sites posting is not allowed as far as I know. Commented Jan 11, 2014 at 20:51
  • @StiffJokes As long as I make a comment about posting it both places and post an answer, given on one side, on the other, too, I don't see the problem. Commented Jan 12, 2014 at 9:53
  • @SvendTveskæg: from a physicians view, it should not be written as 1 and 2
    – user2478
    Commented Jan 12, 2014 at 16:21
  • @Herbert I know. :) Commented Jan 12, 2014 at 16:22
  • 2
    @CodeMocker Cross-Posts are allowed on LaTeX-Community.org, the poster should just include a link, so everybody knows. Can save time. Svend did it perfectly, and as I know a cross-post here is fine as well, just not within different StackExchange sites since they topics separate and focused.
    – Stefan Kottwitz
    Commented Jan 12, 2014 at 20:45

2 Answers 2

5

Here a solution with some internal justification:

\documentclass{article}
\usepackage{pst-plot}
\makeatletter
\def\@LabelComma#1.#2.#3\@nil{%
  \def\pst@tempA{#1}%
  \ifx\pst@tempA\@empty\the\@zero\else#1\fi% the integer part
  \def\pst@tempA{#2}
  \ifx\pst@tempA\@empty
     \@writeDecimals{}%
  \else%
    \ifnum#2=0\relax\else%
      \@writeDecimals{#2}%
   \fi%
 \fi%
}
\makeatother

\begin{document}
\psset{xunit = 2}
\begin{pspicture}(3,1)
\psaxes[Dx = 0.5]{->}(3,1)
\end{pspicture}
\end{document}

output

0
3

A recommended solution with fp.

\documentclass[pstricks,border=24pt,12pt]{standalone}

\usepackage{pst-plot}
\usepackage[nomessages]{fp}


\begin{document}

\psset{xunit = 2}
\begin{pspicture}(3,1)
\psaxes[ticks=none,labels=none]{->}(3,1)
\multido{\r=.0+.5}{6}{\psxTick(\r){\FPeval\temp{clip(\r)}\temp}}
\end{pspicture}

\end{document}

enter image description here

5
  • Does this mean it is not possible to modify the labels of the axes directly?
    – cgnieder
    Commented Jan 12, 2014 at 10:15
  • @cgnieder Good point. What you are asking for is exactly what I would like. Commented Jan 12, 2014 at 10:16
  • @cgnieder: I don't know the internal details of PSTricks. Herbert might be able to answer your question. :-) Commented Jan 12, 2014 at 10:17
  • What would be the output with the other step value: \multido{\r=.0+.4}{6}?
    – g.kov
    Commented Jan 12, 2014 at 11:34
  • @g.kov: Then use the more accurate one \n instead of \r, \multido{\n=.0+.4}{6}{\psxTick(\n){\FPeval\temp{clip(\n)}\temp}}. Commented Jan 12, 2014 at 16:32

You must log in to answer this question.

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