PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : PsTricks, Brüche in den Achsenlabels



jbecker
29-08-2016, 09:08
Hallo

Wie kann man die Minuszeichen in den Labels (s. Minimalbeispiel) vor den Bruchstrich setzen?



\documentclass{scrartcl}
\usepackage{pstricks}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-4,-4)(4,4)
\psset{fractionLabels,fractionLabelBase=3,unit=1cm }
\psaxes{->}(0,0)(-4,-4)(4,4)
\end{pspicture}
\end{document}


Vielen Dank für Eure Hilfe

rais
29-08-2016, 20:49
Wie kann man die Minuszeichen in den Labels (s. Minimalbeispiel) vor den Bruchstrich setzen?

so niemand eine bessere Idee hat, müsstest Du dazu \setFractionhLabels und \setFractionvLabels anpassen (und damit auch \pshlabel/\psvlabel).
Hier exemplarisch der Versuch, \setFractionvLabels (\psvlabel) anzupassen:


\documentclass{scrartcl}
\usepackage{pst-plot}
\newcounter{tmpX}
\makeatletter
\renewcommand*\setFractionvLabels{%
\def\pst@@@vlabel##1{\psvlabel{##1}}
\def\psvlabel##1{%
\ifnum\psk@yfractionLabelBase<2 \def\de@nominator{\@ne}\else\def\de@nominator{\psk @yfractionLabelBase}\fi
\def\pst@tempA{##1}%
\pst@abs{\pst@tempA}\pst@cntm
\setcounter{tmpX}{\numexpr-\pst@tempA\relax}% + 2016-08-29
\pst@mod{\pst@cntm}{\de@nominator}\pst@cntp % cntb=##1 modulo trigLabelBase
\ifnum\@ne>\pst@cntp % 1 > modulo -> then we have pi/x
\pst@cnto=\pst@cntm \divide\pst@cnto by \de@nominator
\ifPst@ymathLabel$\psk@ylabelFontSize\ifnum\pst@te mpA<0 -\fi\the\pst@cnto\psk@ylabelFactor$%
\else \psk@ylabelFontSize\ifnum\pst@tempA<0 -\fi\the\pst@cnto\psk@ylabelFactor
\fi
\else
\ifPst@ymathLabel
$\psk@ylabelFontSize
\ifnum\pst@cntp=\@ne % < 1? $
\if\pst@cntm=\@ne
\frac{1}{\de@nominator}\psk@ylabelFactor% % 1/x
\else\ifnum\pst@tempA=-1 -\frac{1}{\de@nominator}\psk@ylabelFactor% mod 2016-08-29: \frac{-1} --> -\frac{1}
\else \ifnum\pst@tempA=1 \frac{1}{\de@nominator}\psk@ylabelFactor%
\else
\ifnum\pst@tempA<0 %+ 2016-08-29
-\frac{\the\value{tmpX}}{\de@nominator}\psk@ylabelF actor% + 2016-08-29
\else %+ 2016-08-29
\frac{\pst@tempA}{\de@nominator}\psk@ylabelFactor% x/y
\fi %+ 2016-08-29
\fi\fi\fi
\else
\ifnum\pst@tempA=1 \frac{1}{\de@nominator}\psk@ylabelFactor%
\else\ifnum\pst@tempA=\de@nominator 1\psk@xlabelFactor \else
\ifnum\pst@tempA<0 %+ 2016-08-29
-\frac{\the\value{tmpX}}{\de@nominator}\psk@ylabelF actor% + 2016-08-29
\else %+ 2016-08-29
\frac{\pst@tempA}{\de@nominator}\psk@ylabelFactor%
\fi %+ 2016-08-29
\fi\fi\fi$
\else
\psk@ylabelFontSize
\ifnum\pst@cntp=\@ne% % < 1?
\if\pst@cntm=\@ne
$\frac{1}{\de@nominator}\psk@ylabelFactor$% % 1/x
\else\ifnum\pst@tempA=-1 $\frac{-1}{\de@nominator}\psk@ylabelFactor$%
\else \ifnum\pst@tempA=1 $\frac{1}{\de@nominator}\psk@ylabelFactor$%
\else$\frac{\pst@tempA}{\de@nominator}\psk@ylabelF actor$% x/y
\fi\fi\fi%
\else%
\ifnum\pst@tempA=1 $\frac{1}{\de@nominator}\psk@ylabelFactor$%
\else\ifnum\pst@tempA=\de@nominator 1\psk@ylabelFactor
\else$\frac{\pst@tempA}{\de@nominator}\psk@ylabelF actor$% %$
\fi\fi\fi
\fi
\fi
}%
}%$
\makeatother
\begin{document}
\begin{pspicture}(-4,-4)(4,4)
\psset{fractionLabels,fractionLabelBase=3,unit=1cm }
\psaxes{->}(0,0)(-4,-4)(4,4)
\end{pspicture}
\end{document}

VG

jbecker
30-08-2016, 08:30
Vielen Dank!

Für Interessierte, noch um die entsprechende Anpassung für die x-Achse ergänzt:



\documentclass{scrartcl}
\usepackage{pstricks}
\usepackage{pst-plot}
\newcounter{tmpX}
\newcounter{tmpY}
\makeatletter
\renewcommand*\setFractionvLabels{%
\def\pst@@@vlabel##1{\psvlabel{##1}}
\def\psvlabel##1{%
\ifnum\psk@yfractionLabelBase<2 \def\de@nominator{\@ne}\else\def\de@nominator{\psk @yfractionLabelBase}\fi
\def\pst@tempA{##1}%
\pst@abs{\pst@tempA}\pst@cntm
\setcounter{tmpX}{\numexpr-\pst@tempA\relax}% + 2016-08-29
\pst@mod{\pst@cntm}{\de@nominator}\pst@cntp % cntb=##1 modulo trigLabelBase
\ifnum\@ne>\pst@cntp % 1 > modulo -> then we have pi/x
\pst@cnto=\pst@cntm \divide\pst@cnto by \de@nominator
\ifPst@ymathLabel$\psk@ylabelFontSize\ifnum\pst@te mpA<0 -\fi\the\pst@cnto\psk@ylabelFactor$%
\else \psk@ylabelFontSize\ifnum\pst@tempA<0 -\fi\the\pst@cnto\psk@ylabelFactor
\fi
\else
\ifPst@ymathLabel
$\psk@ylabelFontSize
\ifnum\pst@cntp=\@ne % < 1? $
\if\pst@cntm=\@ne
\frac{1}{\de@nominator}\psk@ylabelFactor% % 1/x
\else\ifnum\pst@tempA=-1 -\frac{1}{\de@nominator}\psk@ylabelFactor% mod 2016-08-29: \frac{-1} --> -\frac{1}
\else \ifnum\pst@tempA=1 \frac{1}{\de@nominator}\psk@ylabelFactor%
\else
\ifnum\pst@tempA<0 %+ 2016-08-29
-\frac{\the\value{tmpX}}{\de@nominator}\psk@ylabelF actor% + 2016-08-29
\else %+ 2016-08-29
\frac{\pst@tempA}{\de@nominator}\psk@ylabelFactor% x/y
\fi %+ 2016-08-29
\fi\fi\fi
\else
\ifnum\pst@tempA=1 \frac{1}{\de@nominator}\psk@ylabelFactor%
\else\ifnum\pst@tempA=\de@nominator 1\psk@xlabelFactor \else
\ifnum\pst@tempA<0 %+ 2016-08-29
-\frac{\the\value{tmpX}}{\de@nominator}\psk@ylabelF actor% + 2016-08-29
\else %+ 2016-08-29
\frac{\pst@tempA}{\de@nominator}\psk@ylabelFactor%
\fi %+ 2016-08-29
\fi\fi\fi$
\else
\psk@ylabelFontSize
\ifnum\pst@cntp=\@ne% % < 1?
\if\pst@cntm=\@ne
$\frac{1}{\de@nominator}\psk@ylabelFactor$% % 1/x
\else\ifnum\pst@tempA=-1 $\frac{-1}{\de@nominator}\psk@ylabelFactor$%
\else \ifnum\pst@tempA=1 $\frac{1}{\de@nominator}\psk@ylabelFactor$%
\else$\frac{\pst@tempA}{\de@nominator}\psk@ylabelF actor$% x/y
\fi\fi\fi%
\else%
\ifnum\pst@tempA=1 $\frac{1}{\de@nominator}\psk@ylabelFactor$%
\else\ifnum\pst@tempA=\de@nominator 1\psk@ylabelFactor
\else$\frac{\pst@tempA}{\de@nominator}\psk@ylabelF actor$% %$
\fi\fi\fi
\fi
\fi
}%
}%$
\renewcommand*\setFractionhLabels{%
\def\pst@@@hlabel##1{\pshlabel{##1}}
\def\pshlabel##1{%
\ifnum\psk@xfractionLabelBase<2 \def\de@nominator{\@ne}\else\def\de@nominator{\psk @xfractionLabelBase}\fi
\def\pst@tempA{##1}%
\pst@abs{\pst@tempA}\pst@cntm
\setcounter{tmpY}{\numexpr-\pst@tempA\relax}% + 2016-08-29
\pst@mod{\pst@cntm}{\de@nominator}\pst@cntp % cntb=##1 modulo trigLabelBase
\ifnum\@ne>\pst@cntp % 1 > modulo -> then we have pi/x
\pst@cnto=\pst@cntm \divide\pst@cnto by \de@nominator
\ifPst@ymathLabel$\psk@xlabelFontSize\ifnum\pst@te mpA<0 -\fi\the\pst@cnto\psk@xlabelFactor$%
\else \psk@xlabelFontSize\ifnum\pst@tempA<0 -\fi\the\pst@cnto\psk@xlabelFactor
\fi
\else
\ifPst@xmathLabel
$\psk@xlabelFontSize
\ifnum\pst@cntp=\@ne % < 1? $
\if\pst@cntm=\@ne
\frac{1}{\de@nominator}\psk@xlabelFactor% % 1/x
\else\ifnum\pst@tempA=-1 -\frac{1}{\de@nominator}\psk@xlabelFactor% mod 2016-08-29: \frac{-1} --> -\frac{1}
\else \ifnum\pst@tempA=1 \frac{1}{\de@nominator}\psk@xlabelFactor%
\else
\ifnum\pst@tempA<0 %+ 2016-08-29
-\frac{\the\value{tmpY}}{\de@nominator}\psk@xlabelF actor% + 2016-08-29
\else %+ 2016-08-29
\frac{\pst@tempA}{\de@nominator}\psk@xlabelFactor% x/y
\fi %+ 2016-08-29
\fi\fi\fi
\else
\ifnum\pst@tempA=1 \frac{1}{\de@nominator}\psk@xlabelFactor%
\else\ifnum\pst@tempA=\de@nominator 1\psk@ylabelFactor \else
\ifnum\pst@tempA<0 %+ 2016-08-29
-\frac{\the\value{tmpY}}{\de@nominator}\psk@xlabelF actor% + 2016-08-29
\else %+ 2016-08-29
\frac{\pst@tempA}{\de@nominator}\psk@xlabelFactor%
\fi %+ 2016-08-29
\fi\fi\fi$
\else
\psk@xlabelFontSize
\ifnum\pst@cntp=\@ne% % < 1?
\if\pst@cntm=\@ne
$\frac{1}{\de@nominator}\psk@xlabelFactor$% % 1/x
\else\ifnum\pst@tempA=-1 $\frac{-1}{\de@nominator}\psk@xlabelFactor$%
\else \ifnum\pst@tempA=1 $\frac{1}{\de@nominator}\psk@xlabelFactor$%
\else$\frac{\pst@tempA}{\de@nominator}\psk@xlabelF actor$% x/y
\fi\fi\fi%
\else%
\ifnum\pst@tempA=1 $\frac{1}{\de@nominator}\psk@xlabelFactor$%
\else\ifnum\pst@tempA=\de@nominator 1\psk@xlabelFactor
\else$\frac{\pst@tempA}{\de@nominator}\psk@xlabelF actor$% %$
\fi\fi\fi
\fi
\fi
}%
}%$
\makeatother
\begin{document}
\begin{pspicture}(-4,-4)(4,4)
\psset{fractionLabels,fractionLabelBase=3,unit=1cm }
\psaxes{->}(0,0)(-4,-4)(4,4)
\end{pspicture}
\end{document}