PSTricks 图中出现意外的轴标签

PSTricks 图中出现意外的轴标签

请考虑以下示例:

\documentclass{article}

\usepackage{pstricks-add}
\usepackage{expl3}

\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff

\newcommand*\Angle{\calc{360/\NoNodes}}
\newcommand*\xMinAxes{\calc{\xCentre-\radius-0.5}}
\newcommand*\yMinAxes{\calc{\yCentre-\radius-0.5}}
\newcommand*\xMaxAxes{\calc{\xCentre+\radius+0.7}}
\newcommand*\yMaxAxes{\calc{\yCentre+\radius+0.7}}
\newcommand*\xMinPicture{\xMinAxes}
\newcommand*\yMinPicture{\yMinAxes}
\newcommand*\xMaxPicture{\calc{\xMaxAxes+0.35}}
\newcommand*\yMaxPicture{\calc{\yMaxAxes+0.4}}

\def\radius{3}
\def\NoNodes{8}
\def\xCentre{1}
\def\yCentre{2}


\begin{document}

\begin{pspicture}(\xMinPicture,\yMinPicture)(\xMaxPicture,\yMaxPicture)
  \psaxes{->}(\xCentre,\yCentre)(\xMinAxes,\yMinAxes)(\xMaxAxes,\yMaxAxes)
    [$x$,0][$y$,90]
  \pnode(\xCentre,\yCentre){C}
  \pscircle(C){\radius}
  \qdisk(C){2pt}
  \uput[45](C){$(\xCentre,\yCentre)$}
  \multido{\r = 0+\Angle}{\NoNodes}{%
    \psRelLine[angle = \r, linestyle = none]
      (C)(\calc{\xCentre+\radius},\yCentre){1}{A}
    \qdisk(A){2pt}}
\end{pspicture}

\end{document}

输出

我预计(在这种特殊情况下) x 轴上的标签范围从 -2 到 4,y 轴上的标签范围从 -1 到 5;我该如何实现这一点?

答案1

完整示例:

\documentclass{article}
\usepackage{pstricks-add}
\usepackage{expl3}

\ExplSyntaxOn
  \cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff
\def\radius{3}
\def\NoNodes{8}
\def\xCentre{1}
\def\yCentre{2}
\edef\Angle{\calc{360/\NoNodes}}
\edef\xMinAxes{\calc{\xCentre-\radius-0.5}}
\edef\yMinAxes{\calc{\yCentre-\radius-0.5}}
\edef\xMaxAxes{\calc{\xCentre+\radius+0.7}}
\edef\yMaxAxes{\calc{\yCentre+\radius+0.7}}
\edef\xMinPicture{\xMinAxes}
\edef\yMinPicture{\yMinAxes}
\edef\xMaxPicture{\calc{\xMaxAxes+0.35}}
\edef\yMaxPicture{\calc{\yMaxAxes+0.4}}

\begin{document}

\begin{pspicture}(\xMinPicture,\yMinPicture)(\xMaxPicture,\yMaxPicture)
  \psaxes[Ox=\xCentre,Oy=\yCentre]{->}(\xCentre,\yCentre)(\xMinAxes,\yMinAxes)(\xMaxAxes,\yMaxAxes)[$x$,0][$y$,90]
\end{pspicture}

\end{document}

答案2

介绍包的威力fp

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


\FPset\radius{3}
\FPset\NoNodes{8}
\FPset\xCentre{1}
\FPset\yCentre{2}

\FPeval\Angle{round(360/NoNodes:6)}
\FPeval\xMinAxes{round(xCentre-radius-0.5:6)}
\FPeval\yMinAxes{round(yCentre-radius-0.5:6)}
\FPeval\xMaxAxes{round(xCentre+radius+0.7:6)}
\FPeval\yMaxAxes{round(yCentre+radius+0.7:6)}

\FPset\xMinPicture{xMinAxes}
\FPset\yMinPicture{yMinAxes}

\FPeval\xMaxPicture{round(xMaxAxes+0.35:6)}
\FPeval\yMaxPicture{round(yMaxAxes+0.4:6)}

\begin{document}

\begin{pspicture}(\xMinPicture,\yMinPicture)(\xMaxPicture,\yMaxPicture)
  \psaxes[Ox=\xCentre,Oy=\yCentre]{->}(\xCentre,\yCentre)(\xMinAxes,\yMinAxes)(\xMaxAxes,\yMaxAxes)[$x$,0][$y$,90]
\end{pspicture}

\end{document}

相关内容