如何使 的主刻度\psgraph
与 的主网格对齐\psgrid
?
\documentclass[pstricks,border=0bp,12pt,dvipsnames]{standalone}
\usepackage{pst-plot}
\usepackage[nomessages]{fp}
\FPset\TrigLabelBase{4}
\FPeval\XMin{0-pi}
\FPeval\XMax{2*pi}
\FPset\YMin{-3}
\FPset\YMax{3}
\FPeval\DeltaX{pi/TrigLabelBase}
\FPeval\DeltaY{1}
\FPeval\Left{XMin-DeltaX/2}
\FPeval\Right{XMax+DeltaX/2}
\FPeval\Bottom{YMin-DeltaY/4}
\FPeval\Top{YMax+DeltaY/4}
\newlength\Width\Width=12cm
\newlength\Height\Height=6cm
\newlength\urx\urx=15pt
\newlength\ury\ury=15pt
\newlength\llx\llx=-5pt
\newlength\lly\lly=-5pt
\newpsstyle{gridstyle}
{
gridwidth=0.4pt,% 0.8pt
gridcolor=red!20,% black
griddots=0,% 0
%=====================================
gridlabels=0pt,% 10pt
gridfont=NimbusSanL-Regu,
gridlabelcolor=blue!50,% black, must not use dvipsnames
%=====================================
subgriddiv=10,% 5
subgridwidth=0.1pt,% 0.4pt
subgridcolor=green!50,% gray
subgriddots=0% 0
}
\psset
{
urx=\urx,
ury=\ury,
llx=\llx,
lly=\lly,
trigLabels,
trigLabelBase=\TrigLabelBase,
xAxisLabel=$x$,
yAxisLabel=$y$,
tickcolor=gray,
ticksize=0 -4pt,
labelFontSize=\scriptstyle,
style=gridstyle,
}
\begin{document}
\begin{psgraph}[dx=\DeltaX,dy=\DeltaY,linecolor=gray]{->}(0,0)(\Left,\Bottom)(\Right,\Top){\dimexpr\Width-\urx+\llx}{!}%{\dimexpr\Height-\ury+\lly}
\psgrid[xunit=\DeltaX,dx=\DeltaX](\Left,\Bottom)(\Right,\Top)
\end{psgraph}
\end{document}
答案1
请提供最小例子而不是那些夸张的例子...
\psgrid[xunit=\DeltaX](-4,-3)(8,3)% 4 ticks left, 8 ticks right
替代:
\documentclass[pstricks,border=0bp,12pt,dvipsnames]{standalone}
\usepackage{pst-plot}
\psset{urx=1cm,ury=1cm,llx=-1cm,lly=-1cm,
trigLabels,trigLabelBase=4,
xAxisLabel=$x$,yAxisLabel=$y$,tickcolor=gray,
labelFontSize=\scriptstyle}
\pstFPdiv\DeltaX{\psPi}{4}
\begin{document}
\begin{psgraph}[dx=\DeltaX,linecolor=gray]{->}(0,0)(-3.1415,-3)(6.283,3){12cm}{!}
\psaxes[linecolor=gray,dx=\DeltaX,labels=none,subticks=10,subtickwidth=0.1pt,
subtickcolor=green!50,tickcolor=red!50,
xticksize=-3 3,yticksize=-\psPi\space \psPiTwo,subticksize=1](0,0)(-\psPi,-3)(\psPiTwo,3)
\end{psgraph}
\end{document}
\psgrid
总是使用自然数作为 x|y 面积。
答案2
只是为了分享我基于 Herbert 解决方案的模板以及我自己的夸张但易于使用的设置。
有关设置的说明
模板
\documentclass[pstricks,border=0pt,12pt,dvipsnames]{standalone}
\usepackage{pst-plot}
\usepackage[nomessages]{fp}
\FPeval\XMin{0-pi}
\FPeval\XMax{2*pi}
\FPeval\YMin{0-pi}
\FPeval\YMax{3*pi/2}
\FPeval\XOL{0-1/3} % of DeltaX
\FPeval\XOR{1/3} % of DeltaX
\FPeval\YOB{0-1/3} % of DeltaY
\FPeval\YOT{1/3} % of DeltaY
\FPset\TrigLabelBase{2}
\FPeval\DeltaX{pi/TrigLabelBase}
\FPeval\DeltaY{pi/TrigLabelBase}
\FPeval\AxisL{XMin+DeltaX*XOL}
\FPeval\AxisR{XMax+DeltaX*XOR}
\FPeval\AxisB{YMin+DeltaY*YOB}
\FPeval\AxisT{YMax+DeltaY*YOT}
\newlength\Width\Width=12cm
\newlength\Height\Height=8cm
\newlength\llx\llx=-5pt
\newlength\urx\urx=15pt
\newlength\lly\lly=-5pt
\newlength\ury\ury=15pt
\psset
{
llx=\llx,
lly=\lly,
urx=\urx,
ury=\ury,
xtrigLabels,
ytrigLabels,
trigLabelBase=\TrigLabelBase,
labelFontSize=\scriptstyle,
xAxisLabel=$x$,
yAxisLabel=$y$,
}
\begin{document}
\begin{psgraph}
[
dx=\DeltaX,
dy=\DeltaY,
linecolor=gray,
tickcolor=gray,
ticksize=-3pt 3pt,
axespos=top,
]{<->}(0,0)(\AxisL,\AxisB)(\AxisR,\AxisT){\dimexpr\Width-\urx+\llx}{!}%{\dimexpr\Height-\ury+\lly}
\psaxes
[
dx=\DeltaX,
dy=\DeltaY,
labels=none,
subticks=5,
tickwidth=.4pt,
subtickwidth=.2pt,
tickcolor=Red!30,
subtickcolor=ForestGreen!30,
xticksize=\YMin\space \YMax,
yticksize=\XMin\space \XMax,
subticksize=1,
](0,0)(\XMin,\YMin)(\XMax,\YMax)
\end{psgraph}
\end{document}