r - 无法在箱线图中设置轴的间隔:RStudio
问题描述
我正在尝试从大型数据集中制作箱线图。由于间隔很大,箱线图看起来不太好。我想修复 y 轴的间隔,但它给了我错误。为了您的方便,我正在添加我的代码和图表
我的代码:
boxplot(POS$Profit.Amount~POS$BA.Node, xlab="Location",
ylab = "Amount of Profit", main="Profit Per Location", col=colors, axis(2, seq(0,100,10)))
解决方案
您可以在 boxplot 函数中结合使用 ylim 和 yaxp 选项来解决这个问题:
#create some random data
y=runif(500, 20, 80)
#plot
boxplot(y, xlab="Location",
ylab = "Amount of Profit",
main="Profit Per Location", yaxp= c(0,100, 10), ylim=c(0,100))
上面的代码将限制设置为 0 和 100,而 yaxp 将在 0 和 100 之间创建 10 个分区。
推荐阅读
- boost - 无法链接到 cmake 导入的目标
- excel - 设置多选项字段的linkedcell
- pine-script - 松脚本检查未来吧
- javascript - 使用javascript删除url参数
- python-3.x - pySpark 问题:map/parallelize 未按预期工作
- r - 用 R 中具有相同 ID 的不同数据帧中的行中的值替换列中的 NA
- javascript - 在数组数组上运行函数 - js
- agora.io - 从 AgoraRTCSDK 生成 dSYM 时的警告
- apache-spark - 当窗口/分区使用前向填充时,将条件添加到 pyspark sql 中的 last() 函数
- python - matplotlib Gridspec 子图出乎意料的不同大小