Polar Plots in PGFPlots
Create polar coordinate plots, radar charts, and circular diagrams.
Setup for Polar Plots
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=1.18}Basic Polar Plot
\begin{tikzpicture}
\begin{polaraxis}
\addplot[blue, thick, domain=0:360, samples=100] {1};
\end{polaraxis}
\end{tikzpicture}Common Polar Curves
\begin{tikzpicture}
\begin{polaraxis}[
title={Rose Curves}
]
% Circle
\addplot[blue, thick, domain=0:360, samples=100] {1};
% Cardioid: r = 1 + cos(theta)
\addplot[red, thick, domain=0:360, samples=100] {1 + cos(x)};
% Rose curve: r = cos(3*theta)
\addplot[green!60!black, thick, domain=0:360, samples=200] {cos(3*x)};
% Spiral: r = theta/180
\addplot[orange, thick, domain=0:720, samples=200] {x/180};
\end{polaraxis}
\end{tikzpicture}Polar Data Points
\begin{tikzpicture}
\begin{polaraxis}[
xtick={0, 45, 90, 135, 180, 225, 270, 315},
xticklabels={N, NE, E, SE, S, SW, W, NW}
]
% Data points (angle, radius)
\addplot[only marks, mark=*, blue] coordinates {
(0, 3)
(45, 2.5)
(90, 4)
(135, 3.5)
(180, 2)
(225, 3)
(270, 4.5)
(315, 2.8)
};
% Connected line
\addplot[red, thick] coordinates {
(0, 3)
(45, 2.5)
(90, 4)
(135, 3.5)
(180, 2)
(225, 3)
(270, 4.5)
(315, 2.8)
(360, 3) % Close the shape
};
\end{polaraxis}
\end{tikzpicture}Radar/Spider Chart
\begin{tikzpicture}
\begin{polaraxis}[
xtick={0, 60, 120, 180, 240, 300},
xticklabels={Speed, Power, Defense, Magic, Stamina, Luck},
ymin=0, ymax=100,
ytick={20, 40, 60, 80, 100},
legend pos=outer north east
]
% Character 1
\addplot[blue, thick, fill=blue, fill opacity=0.2] coordinates {
(0, 80)
(60, 60)
(120, 70)
(180, 50)
(240, 90)
(300, 40)
(360, 80)
};
% Character 2
\addplot[red, thick, fill=red, fill opacity=0.2] coordinates {
(0, 50)
(60, 90)
(120, 40)
(180, 85)
(240, 60)
(300, 75)
(360, 50)
};
\legend{Warrior, Mage}
\end{polaraxis}
\end{tikzpicture}Filled Polar Regions
\begin{tikzpicture}
\begin{polaraxis}
% Filled cardioid
\addplot[
fill=blue!30,
draw=blue,
thick,
domain=0:360,
samples=100
] {1 + cos(x)} \closedcycle;
\end{polaraxis}
\end{tikzpicture}Wind Rose / Directional Data
\begin{tikzpicture}
\begin{polaraxis}[
xtick={0, 22.5, 45, 67.5, 90, 112.5, 135, 157.5, 180,
202.5, 225, 247.5, 270, 292.5, 315, 337.5},
xticklabels={N, NNE, NE, ENE, E, ESE, SE, SSE, S,
SSW, SW, WSW, W, WNW, NW, NNW},
xticklabel style={font=\tiny},
ymin=0
]
% Bar-like representation for wind frequency
\addplot[
ybar,
bar width=15,
fill=blue!60
] coordinates {
(0, 12) (22.5, 8) (45, 15) (67.5, 10)
(90, 5) (112.5, 3) (135, 7) (157.5, 9)
(180, 11) (202.5, 14) (225, 18) (247.5, 16)
(270, 20) (292.5, 17) (315, 13) (337.5, 10)
};
\end{polaraxis}
\end{tikzpicture}Polar Axis Customization
\begin{tikzpicture}
\begin{polaraxis}[
% Angle settings
xtick={0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330},
xmin=0, xmax=360,
% Radius settings
ymin=0, ymax=5,
ytick={1, 2, 3, 4, 5},
ylabel={Radius},
% Grid
grid=both,
minor tick num=1,
% Title
title={Custom Polar Plot}
]
\addplot[blue, thick, domain=0:360, samples=100] {2 + sin(3*x)};
\end{polaraxis}
\end{tikzpicture}Next Steps
Continue learning PGFPlots:
- Error Bars - Uncertainty visualization
- Legends - Legend customization
- Axis Customization - Advanced axis options
Polar Plots in PGFPlots
Create polar coordinate plots, radar charts, and circular diagrams.
Setup for Polar Plots
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=1.18}Basic Polar Plot
\begin{tikzpicture}
\begin{polaraxis}
\addplot[blue, thick, domain=0:360, samples=100] {1};
\end{polaraxis}
\end{tikzpicture}Common Polar Curves
\begin{tikzpicture}
\begin{polaraxis}[
title={Rose Curves}
]
% Circle
\addplot[blue, thick, domain=0:360, samples=100] {1};
% Cardioid: r = 1 + cos(theta)
\addplot[red, thick, domain=0:360, samples=100] {1 + cos(x)};
% Rose curve: r = cos(3*theta)
\addplot[green!60!black, thick, domain=0:360, samples=200] {cos(3*x)};
% Spiral: r = theta/180
\addplot[orange, thick, domain=0:720, samples=200] {x/180};
\end{polaraxis}
\end{tikzpicture}Polar Data Points
\begin{tikzpicture}
\begin{polaraxis}[
xtick={0, 45, 90, 135, 180, 225, 270, 315},
xticklabels={N, NE, E, SE, S, SW, W, NW}
]
% Data points (angle, radius)
\addplot[only marks, mark=*, blue] coordinates {
(0, 3)
(45, 2.5)
(90, 4)
(135, 3.5)
(180, 2)
(225, 3)
(270, 4.5)
(315, 2.8)
};
% Connected line
\addplot[red, thick] coordinates {
(0, 3)
(45, 2.5)
(90, 4)
(135, 3.5)
(180, 2)
(225, 3)
(270, 4.5)
(315, 2.8)
(360, 3) % Close the shape
};
\end{polaraxis}
\end{tikzpicture}Radar/Spider Chart
\begin{tikzpicture}
\begin{polaraxis}[
xtick={0, 60, 120, 180, 240, 300},
xticklabels={Speed, Power, Defense, Magic, Stamina, Luck},
ymin=0, ymax=100,
ytick={20, 40, 60, 80, 100},
legend pos=outer north east
]
% Character 1
\addplot[blue, thick, fill=blue, fill opacity=0.2] coordinates {
(0, 80)
(60, 60)
(120, 70)
(180, 50)
(240, 90)
(300, 40)
(360, 80)
};
% Character 2
\addplot[red, thick, fill=red, fill opacity=0.2] coordinates {
(0, 50)
(60, 90)
(120, 40)
(180, 85)
(240, 60)
(300, 75)
(360, 50)
};
\legend{Warrior, Mage}
\end{polaraxis}
\end{tikzpicture}Filled Polar Regions
\begin{tikzpicture}
\begin{polaraxis}
% Filled cardioid
\addplot[
fill=blue!30,
draw=blue,
thick,
domain=0:360,
samples=100
] {1 + cos(x)} \closedcycle;
\end{polaraxis}
\end{tikzpicture}Wind Rose / Directional Data
\begin{tikzpicture}
\begin{polaraxis}[
xtick={0, 22.5, 45, 67.5, 90, 112.5, 135, 157.5, 180,
202.5, 225, 247.5, 270, 292.5, 315, 337.5},
xticklabels={N, NNE, NE, ENE, E, ESE, SE, SSE, S,
SSW, SW, WSW, W, WNW, NW, NNW},
xticklabel style={font=\tiny},
ymin=0
]
% Bar-like representation for wind frequency
\addplot[
ybar,
bar width=15,
fill=blue!60
] coordinates {
(0, 12) (22.5, 8) (45, 15) (67.5, 10)
(90, 5) (112.5, 3) (135, 7) (157.5, 9)
(180, 11) (202.5, 14) (225, 18) (247.5, 16)
(270, 20) (292.5, 17) (315, 13) (337.5, 10)
};
\end{polaraxis}
\end{tikzpicture}Polar Axis Customization
\begin{tikzpicture}
\begin{polaraxis}[
% Angle settings
xtick={0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330},
xmin=0, xmax=360,
% Radius settings
ymin=0, ymax=5,
ytick={1, 2, 3, 4, 5},
ylabel={Radius},
% Grid
grid=both,
minor tick num=1,
% Title
title={Custom Polar Plot}
]
\addplot[blue, thick, domain=0:360, samples=100] {2 + sin(3*x)};
\end{polaraxis}
\end{tikzpicture}Next Steps
Continue learning PGFPlots:
- Error Bars - Uncertainty visualization
- Legends - Legend customization
- Axis Customization - Advanced axis options