Click the Original, Code and Reconstruction tabs to read about the issues and how they were fixed.

Original


Source:https://i.redd.it/pie-chart-where-the-size-of-each-slice-is-not-proportional-v0-e58jwsfsqxca1.png?s=e9232c1c3d1e4e18985106e34ba4196acbd58b0d


Objective

The visualisation chosen had the following three main issues:

Reference

Code

The following code was used to fix the issues identified in the original.

# load library
library(ggplot2)
library(ggeasy)

# Create test data.
data <- data.frame(
  sector=c("Infrastructure Business","Information Technology","Hydrocarbon",
             "Financial Service","Power","Development Project","Defense Engineering",
             "Heavy Engineering","Other"),
  contribution=c(47,21,13,8,3,3,2,1,2)
)

data_base<-ggplot(data = data,aes(x=reorder(sector,contribution),
                                  y=contribution))
data_base<-data_base+geom_bar(stat = "identity",colour="Black",
                              fill=c("#6FD6FF","#FCEE21","#A9F1DF","#FFC371","#38EF7D","#ffecd2",
                                     "#A890FE","#C6EA8D","#E2D1B3"))+scale_y_continuous(expand = c(0, 0))
data_base<-data_base+geom_text(aes(label=contribution),size=4,vjust=+0.3,hjust=+1.0)+coord_flip()
data_base<-data_base+theme_classic()+scale_fill_viridis_d()
data_base<-data_base+theme(legend.position = "none",axis.text.x = element_text(size = 10),
                           panel.background = element_rect(fill = "white"))
data_base<-data_base+ggeasy::easy_rotate_labels(which = "x",angle = 0)
data_base<-data_base+labs(x="Business sector",y="Percentage contribution")+
  theme(axis.title.x = element_text(size = 15),axis.title.y = element_text(size = 15))
data_base<-data_base+labs(title ="Revenue contribution of each sector in percentage for FY 2022")+
  theme(plot.title =element_text(hjust = 0.6))
data_base<-data_base+theme(plot.subtitle = element_text(hjust = 0.5))

Data Reference

https://www.reddit.com/r/dataisugly/comments/1193e14/pie_chart_where_the_size_of_each_slice_is_not/

Reconstruction

The following plot fixes the main issues in the original.

data_base