Ordered Column
library(tidyverse) # untuk manupulasi, merapikan, & visualisasi data
library(gapminder) # untuk mengakses gapminder dataset
our_palette <-c('#660d20',
'#e59a52',
'#edce79',
'#094568',
'#e1c59a')
ordered_column_df <- gapminder %>%
group_by(continent) %>%
summarize(medianlifeExp = median(lifeExp))
ordered_column <- ordered_column_df %>%
ggplot(aes(x = reorder(continent, -medianlifeExp),
y = medianlifeExp,
color = reorder(continent, -medianlifeExp),
fill = reorder(continent, -medianlifeExp))) +
geom_col(width = .6) +
scale_color_manual(values = our_palette,
guide = 'none') +
scale_fill_manual(values = our_palette,
guide = 'none') +
scale_y_continuous(limits = c(0, 90)) +
theme_minimal() +
theme(
axis.title = element_blank(),
axis.text = element_blank(),
axis.line = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_rect(fill = '#FFFFFF',
color = NA),
plot.background = element_rect(fill = '#FFFFFF',
color = '#FFFFFF')
)