How to rename \pi as another value only for y axis without affecting \pi used in x axis?
I don't think there is (that is, I didn't find) a built-in way to do that. With etoolbox
you can patch the code for the x
and y
labels to add arbitrary definitions:
\usepackage{etoolbox}
\makeatletter
\patchcmd\pst@@vlabels
{\vbox to -\psk@ylabelOffset}
{\YAxis@labelHook@code\vbox to -\psk@ylabelOffset}
{}{\FailedToPatch}
\define@key[psset]{pst-plot}{ExecuteBeforeYLabels}[]{\def\YAxis@labelHook@code{#1}}
\patchcmd\pst@@hlabels
{\ifcase\psk@xlabelPos}
{\XAxis@labelHook@code\ifcase\psk@xlabelPos}
{}{\FailedToPatch}
\define@key[psset]{pst-plot}{ExecuteBeforeXLabels}[]{\def\XAxis@labelHook@code{#1}}
\psset{
ExecuteBeforeYLabels={},
ExecuteBeforeXLabels={},
}
\makeatother
then you just need:
\psset{ExecuteBeforeYLabels={\def\pi{\sqrt{3}}}}
Full code:
\documentclass[pstricks,border={3pt 3pt 15pt 15pt},12pt]{standalone}
\usepackage{pst-plot,pst-calculate}
\usepackage[nomessages]{fp}
\FPset\EPSILON{0.3}
\FPeval\Const{root(2,3)}
\FPeval\Left{0-pi}
\FPeval\Right{2*pi}
\FPeval\Top{Const}
\FPeval\Bottom{0-Const}
\FPset\xTrigLabelBase{4}
\FPset\yTrigLabelBase{3}
\FPset\Dx{1}
\FPset\Dy{1}
\FPeval\dx{pi/xTrigLabelBase*Dx}
\FPeval\dy{Const/yTrigLabelBase*Dy}
\FPeval\XUnit{15/(Right-Left)}
\FPeval\YUnit{6/(Top-Bottom)}
\usepackage{etoolbox}
\makeatletter
\patchcmd\pst@@vlabels
{\vbox to -\psk@ylabelOffset}
{\YAxis@labelHook@code\vbox to -\psk@ylabelOffset}
{}{\FailedToPatch}
\define@key[psset]{pst-plot}{ExecuteBeforeYLabels}[]{\def\YAxis@labelHook@code{#1}}
\patchcmd\pst@@hlabels
{\ifcase\psk@xlabelPos}
{\XAxis@labelHook@code\ifcase\psk@xlabelPos}
{}{\FailedToPatch}
\define@key[psset]{pst-plot}{ExecuteBeforeXLabels}[]{\def\XAxis@labelHook@code{#1}}
\psset{
ExecuteBeforeYLabels={},
ExecuteBeforeXLabels={},
}
\makeatother
\psset
{
xunit=\XUnit,
yunit=\YUnit,
dx=\dx,
Dx=\Dx,
dy=\dy,
Dy=\Dy,
xtrigLabels,
ytrigLabels,
xtrigLabelBase=\xTrigLabelBase,
ytrigLabelBase=\yTrigLabelBase,
showorigin=false,
ExecuteBeforeYLabels={\def\pi{\sqrt{3}}},
% ExecuteBeforeXLabels={\def\pi{\sqrt{3}}},
}
\begin{document}
\begin{pspicture}(\pscalculate{\Left-\EPSILON},\pscalculate{\Bottom-\EPSILON})(\pscalculate{\Right+\EPSILON},\pscalculate{\Top+\EPSILON})
\psplot[algebraic,linecolor=red,plotpoints=100,linewidth=2\pslinewidth]{\Left}{\Right}{\Const*sin(x)}
%\def\pi{\sqrt{3}}
\psaxes{<->}(0,0)(\pscalculate{\Left-\EPSILON},\pscalculate{\Bottom-\EPSILON})(\pscalculate{\Right+\EPSILON},\pscalculate{\Top+\EPSILON})[$x$,0][$y$,90]
\end{pspicture}
\end{document}
\makeatletter
\let\pst@@VLabels\pst@@vlabels
\def\pst@@vlabels{\def\pi{\sqrt3}\pst@@VLabels}
\makeatother
\begin{document}
[...]
\end{document}