Pie charts
The coord_polar()
function converts a planar x-y Cartesian plot to polar coordinates. This can be useful if you are producing pie charts.
We can imagine two forms for pie charts - the typical filled circle, or a colored ring.
Typical pie charts omit all of the non-data ink, which we saw in the themes chapter of the last course. Pie charts are not really better than stacked bar charts, but we'll come back to this point in the next chapter.
A bar plot using mtcars
of the number of cylinders (as a factor), fcyl
, is shown in the console.
Diese Übung ist Teil des Kurses
Intermediate Data Visualization with ggplot2
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Run the code, view the plot, then update it
ggplot(mtcars, aes(x = 1, fill = fcyl)) +
geom_bar()
# Add a polar coordinate system