VISUALISE species AS fill FROM ggsql:penguins
DRAW bar
PROJECT TO polarPolar
The polar coordinate system interprets its primary aesthetic as the angular position relative to the center, and the secondary aesthetic as the distance from the center. It is most often used for pie-charts and radar plots.
Default aesthetics
The polar coordinate system has the following default position aesthetics which will be used if no others have been provided:
- Primary:
radius(distance from center) - Secondary:
angle(angular position)
Users can provide their own aesthetic names if needed. For example, if using x and y aesthetics:
PROJECT y, x TO polarThis maps y to radius and x to angle. This is useful when converting from a cartesian coordinate system without editing all the mappings.
Settings
clip: Should data be removed if it appears outside the bounds of the coordinate system. Defaults totruestart: The starting angle in degrees for the theta scale (-360 to 360). Controls where “0” on the angular axis begins. Defaults to0(12 o’clock position).0= 12 o’clock position (top)90= 3 o’clock position (right)-90or270= 9 o’clock position (left)180= 6 o’clock position (bottom)
end: The ending angle in degrees for the theta scale (-360 to 360). Defaults tostart + 360(a full circle). Use this withstartto create partial polar plots like gauge charts or half-circle visualizations.inner: The inner radius as a proportion (0 to 1) of the outer radius. Defaults to0(no hole). Setting this creates a donut chart where the inner portion is empty.0= full pie (no hole)0.3= donut with 30% hole0.5= donut with 50% hole
Examples
Pie chart using angle/radius aesthetics
Pie chart starting at 3 o’clock
VISUALISE species AS fill FROM ggsql:penguins
DRAW bar
PROJECT TO polar
SETTING start => 90Pie chart starting at 9 o’clock
VISUALISE species AS fill FROM ggsql:penguins
DRAW bar
PROJECT TO polar
SETTING start => -90Half-circle gauge chart
VISUALISE species AS fill FROM ggsql:penguins
DRAW bar
PROJECT TO polar
SETTING start => -90, end => 90This creates a gauge chart spanning from the 9 o’clock to 3 o’clock position (a 180° arc at the top). Note that scale expansion is applied by default so the data does not fill the whole half-circle.
Three-quarter pie chart
VISUALISE species AS fill FROM ggsql:penguins
DRAW bar
PROJECT TO polar
SETTING end => 270This creates a pie chart using only 270° (three-quarters of a circle), starting from 0° (12 o’clock) and ending at 270° (9 o’clock).
Donut chart with 50% hole
VISUALISE species AS fill FROM ggsql:penguins
DRAW bar
PROJECT TO polar
SETTING inner => 0.5This creates a donut chart where the inner 50% of the radius is empty, leaving a ring-shaped visualization.
Donut chart with 30% hole
VISUALISE species AS fill FROM ggsql:penguins
DRAW bar
PROJECT TO polar
SETTING inner => 0.3This creates a donut chart with a smaller hole (30% of the radius).
Half-circle donut chart
VISUALISE species AS fill FROM ggsql:penguins
DRAW bar
PROJECT TO polar
SETTING start => -90, end => 90, inner => 0.5This combines the start, end, and inner settings to create a half-circle donut chart (gauge style) spanning from 9 o’clock to 3 o’clock with a 50% hole.