条形图样式问题
Bar Graph Style issue
我正在尝试创建条形图。
这是我的代码:
ggplot(Bilat2GEO2,aes(x= region_par,y=total_exports))+
geom_col()
这是我的图表
.
所以我想改进样式,因为它看起来不好看。我也想把地区名分开。
要使区域名称可读,请使用 coord_flip()
功能将图表翻转过来。为了使图表看起来更漂亮,请使用 fill=
.
添加颜色
ggplot(iris,aes(x=Species,y=Sepal.Length, fill=Species))+
geom_col()+
coord_flip()
这是一个使用 Iris 数据集的答案,但它会重新排序列,因为我知道这就是清理该图表所需要做的事情
iris %>%
mutate(Species = fct_reorder(Species, -Sepal.Length)) %>%
ggplot(aes(Species, Sepal.Length, group = Species, fill = Species)) +
geom_col()+
scale_fill_manual(values = c("steelblue1", "grey5", "mediumpurple1"))+
theme(axis.text.x = element_text(angle = 70, vjust = 1, hjust=1))+
xlab("")+
ylab("")+
ggtitle("Sepal Length",
subtitle = "by Species")
我正在尝试创建条形图。
这是我的代码:
ggplot(Bilat2GEO2,aes(x= region_par,y=total_exports))+
geom_col()
这是我的图表
所以我想改进样式,因为它看起来不好看。我也想把地区名分开。
要使区域名称可读,请使用 coord_flip()
功能将图表翻转过来。为了使图表看起来更漂亮,请使用 fill=
.
ggplot(iris,aes(x=Species,y=Sepal.Length, fill=Species))+
geom_col()+
coord_flip()
这是一个使用 Iris 数据集的答案,但它会重新排序列,因为我知道这就是清理该图表所需要做的事情
iris %>%
mutate(Species = fct_reorder(Species, -Sepal.Length)) %>%
ggplot(aes(Species, Sepal.Length, group = Species, fill = Species)) +
geom_col()+
scale_fill_manual(values = c("steelblue1", "grey5", "mediumpurple1"))+
theme(axis.text.x = element_text(angle = 70, vjust = 1, hjust=1))+
xlab("")+
ylab("")+
ggtitle("Sepal Length",
subtitle = "by Species")