r - 如何将geom_bar的宽度调整为相同的宽度
问题描述
TEMP %>% ggplot(aes(x= Count,y=reorder(Species,Count))) + geom_col(position = "dodge") + ggtitle("Insects abundance during 2017~2019") + ylab("Insects") + xlab("Mean Number") + facet_wrap(~ CLASS,ncol = 1,scales = 'free') + theme_bw()
我想让顶部面板和底部面板具有相同的宽度条。但即使我在geom_col(width = .5)
. 它们的宽度仍然不同。有什么问题。感谢所有关心我问题的人。谢谢。
解决方案
由于您没有发布带有数据的代表,我将只使用 mtcars 数据集。
space
参数 in允许每个方面的facet_grid()
宽度由 x 或 y 值的数量确定。
没有space = "free_y"
:
library(tidyverse)
mtcars %>% ggplot(aes(y = factor(carb))) +
geom_bar(width = 0.5) +
facet_grid(am~., scales = "free")
与space = "free_y"
:
library(tidyverse)
mtcars %>% ggplot(aes(y = factor(carb))) +
geom_bar(width = 0.5) +
facet_grid(am~., scales = "free", space = "free_y")
推荐阅读
- python - 尝试从 python 运行 shell 命令时没有输出
- javascript - NodeJS如何创建类似bash的输入
- android - 如何在 VIPER 架构中使用导航组件?
- javascript - 如何修复 ReactJs 中的“Array.prototype.filter()”警告
- python - 将天更改为年的功能
- video - 为什么 Apple 媒体验证器说零处理段
- android - UWP 找不到任何使用 StartScanningForDevicesAsync 的 BLE 设备(Xamarin 的 Plugin.BLE)
- wms - 如何使用 WMS 并通过 Flutter 获取信息?
- git - 如何在 docker 本地处理分叉存储库(包)?
- node.js - 带有 Puppeteer 给出错误的 Url 的多个屏幕截图:目标应该在 Object.assert 的 targetInfoChanged 之前存在