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.

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).

share|improve this question
    
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. –  Who is crazy first Jan 11 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. –  Svend Tveskæg Jan 12 at 9:53
    
@SvendTveskæg: from a physicians view, it should not be written as 1 and 2 –  Herbert Jan 12 at 16:21
    
@Herbert I know. :) –  Svend Tveskæg Jan 12 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 Jan 12 at 20:45

2 Answers 2

up vote 5 down vote accepted

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

share|improve this answer

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

share|improve this answer
    
Does this mean it is not possible to modify the labels of the axes directly? –  cgnieder Jan 12 at 10:15
    
@cgnieder Good point. What you are asking for is exactly what I would like. –  Svend Tveskæg Jan 12 at 10:16
    
@cgnieder: I don't know the internal details of PSTricks. Herbert might be able to answer your question. :-) –  Who is crazy first Jan 12 at 10:17
    
What would be the output with the other step value: \multido{\r=.0+.4}{6}? –  g.kov Jan 12 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}}. –  Who is crazy first Jan 12 at 16:32

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.