1

Consider the following example:

\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}

output

I expected (in this particular case) the labels on the x-axis to range from -2 to 4 and the labels on the y-axis to range from -1 to 5; how do I achieve this?

1

Complete example:

\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}
  • The point is that I need the calculated values so the example is actually minimal. – Svend Tveskæg Mar 31 '14 at 13:40
  • what has the circle to do with the axis? – user2478 Mar 31 '14 at 13:40
  • I would like to specify the center and the radius for a circle and then draw the axes automatically (i.e., without having to 'hard code' the min and max for the axes values). – Svend Tveskæg Mar 31 '14 at 13:43
2

Introducing the power of fp package.

\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}

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.