suppressMessages(source("R/load.R"))
mtcars %>%
rownames_to_column('index1') %>%
mutate(index1 = index1 %>% as.factor) %>%
mutate(index2 = index1 %>% as.integer) -> df
df %>%
ggplot() +
geom_area(aes(x = index1, y = mpg), color = 'black', fill = 'black') +
coord_flip()
df %>%
ggplot() +
geom_area(aes(x = index2, y = mpg), color = 'black', fill = 'black') +
coord_flip()
df %.>%
ggplot(data = .) +
geom_area(aes(x = index2, y = mpg), color = 'black', fill = 'black') +
coord_flip() +
scale_x_continuous(
breaks = .$index2,
labels = .$index1
)
这里进行说明, 这里还是scale_x_continuous
的 base,
breaks
也不变,还是.$index2
,但是labels = .$index1
进行了修改。