4

The objective is to get fractional labels (not in decimal) for both vertical and horizontal axes.

In my experience, non-trigonometric labels are written in decimals and trigonometric labels can be written in fractional via trigLabels and trigLabelBase. I attempted to abuse these keys to get fractional non-trigonometric by using \let\pi=\relax, but it causes a problem where

  • \pi/n becomes /n (that should be 1/n),

  • -\pi/n becomes -/n (that should be -1/n),

  • -\pi becomes - (that should be -1),

  • \pi becomes <empty> (that should be 1) where <empty> stands for empty .

My question, what is the best trick to convert every \pi to relax but prevent the problems from happening?

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-plot}
\usepackage[nomessages]{fp}

\FPeval\XMin{0-2}
\FPeval\XMax{2}
\FPeval\YMin{0-1}
\FPeval\YMax{1}
\FPeval\temp{1/3}

\psset
{
    ytrigLabels=true,
    xtrigLabels=true,
    trigLabelBase=3,
    unit=3cm,
}

\let\pi=\relax

\begin{document}
\begin{pspicture}(\XMin,\YMin)(\XMax,\YMax)
    \psaxes[dx=\temp,dy=\temp](0,0)(\XMin,\YMin)(\XMax,\YMax)
    \psplot[algebraic,plotpoints=100]{\XMin}{\XMax}{x-2/3}
\end{pspicture}
\end{document}

enter image description here

More general case

Sometimes I need to change \pi to \sqrt{2}, for example. I tried with

\let\pi={\sqrt{2}}

but it does not compile.

2
+50

The version 1.71 from http://texnik.dante.de/tex/generic/pst-plot/ knows fractionLabel:

\errorcontextlines=100
\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-plot}
\psset{fractionLabels,fractionLabelBase=3,unit=3cm}

\begin{document}
\begin{pspicture}(-2,-1)(2,1)
    \psaxes[dx=0.333,dy=0.333](0,0)(-2,-1)(2,1)
    \psplot[algebraic,plotpoints=100]{-2}{2}{x-2/3}
\end{pspicture}
\end{document}

However, there is a spurious space which needs some more investigation.

enter image description here

  • Sorry, is it possible to change \pi with e, \sqrt{m}, etc such that we can have \frac{e}{n}, \frac{\sqrt{m}}{n}, etc where n is the fractionLabelBase? – kiss my armpit Aug 24 '14 at 9:33
  • 1
    for example: xlabelFactor=\sqrt{2} or \def\pi{e} – user2478 Aug 24 '14 at 9:38
  • Sorry. Using xlabelFactor makes the factor appear on the right of the fractional labels rather than in the numerator of the fractional labels. As a result, there are some "oddities" such as -1\sqrt{2} and 1\sqrt{2}. It will be better if we can change \pi in the numerator with \sqrt{2}, for example. – kiss my armpit Aug 24 '14 at 9:49
  • 1
    \def\pi{\sqrt{2}} for example – user2478 Aug 24 '14 at 9:57
  • The update of pst-plot was done on August 24 but up to now it has not been propagated to TeXLive mirrors. A weird thing happened: pst-poly updated on August 28 has been propagated to TeXLive mirrors. – kiss my armpit Sep 1 '14 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.