r - 在 R 中设置边距
问题描述
我在 R 中做一个箱线图,我想标记我的 Y 轴。名字很长,所以我想让底部边距更大以适应它们。我被告知我需要做的是使用该mar()
功能。但似乎无论我在函数中输入什么值,我的边距都不会改变!
我的箱形图如下所示:
我的 R 脚本如下所示:
boxplot(
as.numeric(UEC$Q1_1)[3:21],
as.numeric(UEC$Q1_2)[3:21],
as.numeric(UEC$Q1_3)[3:21],
as.numeric(UEC$Q1_4)[3:21],
as.numeric(UEC$Q1_5)[3:21],
as.numeric(UEC$Q1_6)[3:21],
as.numeric(UEC$Q1_7)[3:21],
as.numeric(UEC$Q1_8)[3:21],
as.numeric(UEC$Q1_9)[3:21],
as.numeric(UEC$Q1_10)[3:21],
as.numeric(UEC$Q1_11)[3:21],
as.numeric(UEC$Q1_12)[3:21],
as.numeric(UEC$Q1_13)[3:21],
as.numeric(UEC$Q1_14)[3:21],
as.numeric(UEC$Q1_15)[3:21],
as.numeric(UEC$Q1_16)[3:21],
as.numeric(UEC$Q1_17)[3:21],
as.numeric(UEC$Q1_18)[3:21],
as.numeric(UEC$Q1_19)[3:21],
as.numeric(UEC$Q1_20)[3:21],
as.numeric(UEC$Q1_21)[3:21],
as.numeric(UEC$Q1_22)[3:21],
as.numeric(UEC$Q1_23)[3:21],
as.numeric(UEC$Q1_24)[3:21],
as.numeric(UEC$Q1_25)[3:21],
as.numeric(UEC$Q1_26)[3:21],
main="UEC Questions",
names=c("annoying/enjoyable", "not understandable/understandable", "creative/dull", "easy to learn/difficult to learn", "valuable/inferior", "boring/exciting", "not interesting/interesting", "unpredictable/predictable", "fast/slow", "inventive/conventional", "obstructive/supportive", "good/bad", "complicated/easy", "unlikable/pleasing", "usual/leading edge", "unpleasant/pleasant", "secure/not secure", "motivating/demotivating", "meets expectations/does not meet expectations", "inefficient/efficient", "clear/confusing", "impractical/practical", "organized/cluttered", "attractive/unattractive", "friendly/unfriendly", "conservative/innovative"),
las=2,
mar=c(5.1, 4.1, 4.1, 2.1)
)
我知道我为利润输入的值可能是错误的,但它们无论如何都不起作用!
谁能建议我哪里出错了?
解决方案
您可以par
在调用之前使用boxplot
.
cex.axis
可以降低 x 轴的字体大小,并且可以mar
弄乱边框周围的间距。
注意顺序是mar=c("bottom-side", "left-side", "upper-side", "right-side")
。
par(cex.axis=0.8, mar=c(8, 4, 5, 2))
boxplot(as.numeric(data$qsec),
as.numeric(data$mpg),
names = c("areallylongtext", "anotherreallylongtext"), las=2)
请注意,您不应该复制/粘贴所有这些as.numeric()
,而应该使用如下示例中的分组变量:
par(cex.axis=0.8, mar=c(10, 4, 5, 2))
boxplot(mpg ~ cyl, data,
names=c("areallylongtext", "anotherreallylongtext", "yetanotherreallylongtext"), las=2)
推荐阅读
- wordpress - Woocommerce:如何在结帐页面上显示唯一一种付款方式的输入收音机?
- java - 设置 JPackage 安装程序,它不会覆盖较新版本中的配置文件
- javascript - 在前端下载ANSI zip文件,由C#后端生成
- javascript - slug 后生成新页面
- c - 从文本文件中读取字符并存储到结构数组中
- vba - 访问 VBA 查询提取并命名
- list - 如何在飞镖中深度复制嵌套列表?
- angular - Angular Fullstory集成如何实现用户uuid
- excel - 使用office.js在线复制粘贴(循环)到多个Excel范围时出错
- python - 当我在 Django 中提交表单集时,为什么它会在表单集中返回额外的 5 个字段?