1

I've been trying to plot coordinates using the polar library of PGFplots, but the plot is just... wrong? Like the points are just not at the right position, and I'm not too sure what I'm missing. I'm pretty sure it may have something to do with using radians instead of degrees, but when I use radians to graph, they turn out fine. I would really prefer not to use degrees, but if it's the only solution, then I'll do the conversions. I'm also struggling to figure out how to change the actual infill color of the nodes. I've been referencing section 4.7.1, and in the code below I use fill, draw, and color, but the infill remains the same. Any help would be greatly appreciated. :)

\documentclass{report}
\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{polar}
\begin{document}
\[
\begin{array}{c|c}
\text{Name}&(r,\theta)\\\hline
A&(1,\dfrac{\pi}{3})\\
B&(2,\dfrac{3\pi}{4})\\
C&(3,\dfrac{7\pi}{6})\\
D&(-1,\dfrac{2\pi}{3})\\
\end{array}\implies\begin{tikzpicture}[baseline=(current bounding box.center)]                                
\begin{polaraxis}[xticklabels={,0,$\frac{\pi}{6}$,$\frac{\pi}{3}$,$\frac{\pi}{2}$,$\frac{2\pi}{3}$,$\frac{5\pi}{6}$,$\pi$,$\frac{7\pi}{6}$,$\frac{4\pi}{3}$,$\frac{3\pi}{2}$,$\frac{5\pi}{3}$,$\frac{11\pi}{6}$}]
\addplot+ [trig format plots=rad, data cs=polarrad,only marks,color=black, mark color=black,draw=black,fill=black,] coordinates {(1,pi/3)(2,3*pi/4)(3,7*pi/6)(-1,2*pi/3)};
\end{polaraxis}
\end{tikzpicture}
\]
\end{document}

enter image description here

New contributor
humanoferth is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • I do not use pgfplots because of how many keys it requires practitioners to remember. However, I would assert that this would be easy to make in plain tikz using a couple of nested for loops and some basic primitives. I can't debug pgfplots though, beyond the basics. Commented yesterday

1 Answer 1

6

Swap the radius and the angle. Write

(pi/3,1)(3*pi/4,2)(7*pi/6,3)(2*pi/3,-1)

instead of

(1,pi/3)(2,3*pi/4)(3,7*pi/6)(-1,2*pi/3)

Example:

\documentclass{report}

\usepackage{amsmath}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{polar}

\begin{document}

\[
\begin{array}{c|c}
\text{Name}&(r,\theta)\\\hline
A&(1,\dfrac{\pi}{3})\\
B&(2,\dfrac{3\pi}{4})\\
C&(3,\dfrac{7\pi}{6})\\
D&(-1,\dfrac{2\pi}{3})\\
\end{array}
\implies
\begin{tikzpicture}[baseline=(current bounding box.center)]                                
  \begin{polaraxis}[
      xticklabels = {,0,$\frac{\pi}{6}$,$\frac{\pi}{3}$,$\frac{\pi}{2}$,$\frac{2\pi}{3}$,$\frac{5\pi}{6}$,$\pi$,$\frac{7\pi}{6}$,$\frac{4\pi}{3}$,$\frac{3\pi}{2}$,$\frac{5\pi}{3}$,$\frac{11\pi}{6}$}
    ]
    \addplot+ [
      % trig format plots=rad % useless here
      ,data cs=polarrad
      ,only marks
      ,color=black
      ,mark color=black
      ,draw=black
      ,fill=black
    ] coordinates {(pi/3,1)(3*pi/4,2)(7*pi/6,3)(2*pi/3,-1)};
\end{polaraxis}
\end{tikzpicture}
\]

\end{document}

Example

2
  • 1
    Not sure how I didn't think of that xd. I had trig format plots=rad in there since it was had fixed my graphs of polar functions, I didn't know it did not apply to points. Thanks sm! Commented yesterday
  • @humanoferth trig format plots set the format for trigonometric functions. Commented yesterday

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.