Customizing the chart
Explode Pie and Donuts.
A pie and donut combo chart is made using the PieDonut() function. The aes() function is used to translate the device and browser columns to the chart’s x- and y-axes, respectively. The extent of each slice of the chart is set using the count parameter.
The degree of separation between the pie chart’s slices is determined by the explode parameter, which is set to 2, which is. Each segment is now isolated from the others in a “exploded” effect. When the explodeDonut parameter is set to TRUE.which separates the segments in the donut chart .
R
PieDonut (devices, aes (x = device, y = browser, count = share), explode = 2, explodeDonut = TRUE , ratioByGroup = FALSE ) |
Explode Pie and Donuts independently.
To explode specific slices in both the Pie and Donut charts independently, the “selected” argument is used. The values passed to “selected” are the indices of the slices to be exploded.
R
PieDonut (devices, aes (x = device, y = browser, count = share), explode = 2, explodeDonut = TRUE , selected = c (2,4,6), ratioByGroup = FALSE ) |
Customize start angle.
To change the starting angle of the chart, the “start” argument is used. The angle is specified in degrees.
R
PieDonut (devices, aes (x = device, y = browser, count = share), explode = 2, explodeDonut = TRUE , selected = c (2,4,6), start = 120, ratioByGroup = FALSE ) |
Add title.
To add a title to the chart, the “title” argument is used. The title is passed as a string.
R
PieDonut (devices, aes (x = device, y = browser, count = share), explode = 2, explodeDonut = TRUE , selected = c (2,4,6), start = 120, title = "Browser market share by device" , ratioByGroup = FALSE ) |
Adjust the radius.
To adjust the radius of the chart, we can use the r0, r1, and r2 arguments of the PieDonut function.
- r0 controls the inner radius of the chart. The default value is 0.4, which means the inner radius is 40% of the total radius.
- r1 controls the outer radius of the chart. The default value is 0.8, which means the outer radius is 80% of the total radius.
- r2 controls the radius of the donut hole. The default value is 0, which means there is no donut hole.
To adjust the radius of the chart, we can change the values of r0, r1, and r2.
To adjust the radius of the chart, we can change the values of r0, r1, and r2.
R
PieDonut (devices, aes (x = device, y = browser, count = share), explode = 2, explodeDonut = TRUE , selected = c (2,4,6), start = 120, title = "Browser market share by device" , r0=0.3,r1=0.6,r2=0.9, ratioByGroup = FALSE ) |
Doughnut plot
To show donut plot without the pie chart:
R
PieDonut (devices, aes (browser, count = share), r0=0.6) |
The devices data frame is used as the input data, and the aes function is used to map the browser variable to the x axis and the share variable to the y axis. The count argument specifies that the share variable should be used to calculate the size of each slice in the plot.
Donut Chart in R
Donut charts are a type of circular chart like pie charts but with hole in the middle. They’re great way for showing data in aeasy-to-see way. If you’re using R, there are loads of packages to make donut charts – think ggplot2, plotly, webr, and others.
Donut charts are used to show data in a circular manner . Since all of the data points are centered on the donut’s rim, it is simple to compare various data points. Additionally, since the size of the slice corresponds to the amount of the data. donut charts can be used to evaluate proportions. Donut charts are a flexible and effective method to show data in general way .
Contact Us