如何固定纵横比并在ggplot2中应用coord_flip? [英] How do I to fix aspect ratio and apply coord_flip in ggplot2?
本文介绍了如何固定纵横比并在ggplot2中应用coord_flip?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在ggplot2中生成以下图表,但我要求它必须是水平图而不是垂直图.我还要求剧情要瘦一些.
Im trying to produce the following chart in ggplot2 but I require it to be a horizontal plot rather than vertical. I also require the plot to be thin.
ggplot(Compositiondata, aes(x=1, y=`Composition`, fill=`Elements`),labels = FALSE)
+ geom_bar(stat="identity",aes(col.axis = "white",labels=FALSE))
+ ggtitle("Title")
+ theme(axis.line=element_blank(), axis.text.x=element_blank(),
axis.ticks.x=element_blank(), axis.title.x=element_blank(),
panel.background=element_blank(), panel.border=element_blank(),
panel.grid.major=element_blank(), panel.grid.minor=element_blank(),
plot.background=element_blank())
+ coord_fixed(ratio = 0.05) +coord_flip()
当我应用 coord_flip()
时,绘图将返回其原始宽度.如何翻转图并保留较小的宽度?
When I apply coord_flip()
the plot returns to its original width.
How can I flip the plot and retain a small width?
推荐答案
没有可复制的数据,我最好的猜测是通过 theme
传递 aspect.ratio
而不是 coord_fixed(ratio = 0.05)
Without reproducible data, my best guess would be to pass aspect.ratio
through the theme
not in coord_fixed(ratio=0.05)
这篇关于如何固定纵横比并在ggplot2中应用coord_flip?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文