gpt4 book ai didi

r - 绘图:轴上的小数点精度

转载 作者:行者123 更新时间:2023-12-02 01:20:45 26 4
gpt4 key购买 nike

我有两列数据,XY,每个条目在两个向量的小数点后都有 4 位数据。

当我使用 plot(x,y) 绘制简单图时,轴上显示的数据精确到小数点后两位。如何在两个轴上将其更改为小数点后 4 位精度?

我添加了下面的示例数据 (inputData),并使用 plot(inputData) 绘制了这些数据。

inputData=structure(list(X = c(33.73521973, 33.622022, 33.63591706, 33.58184488, 
33.73027696, 33.76169838), Y = c(-112.2559051, -112.2396135,
-112.2345327, -112.2441752, -112.2463008, -112.3298128)), .Names = c("X",
"Y"), row.names = c(NA, 6L), class = "data.frame")

我想要一个关于上述数据集的可重现示例,以及建议答案的一部分。

> inputData
X Y
1 33.73522 -112.2559
2 33.62202 -112.2396
3 33.63592 -112.2345
4 33.58184 -112.2442
5 33.73028 -112.2463
6 33.76170 -112.3298

enter image description here

最佳答案

一种选择是使用axis来自定义标签。这里是使用默认绘图轴和使用 axis 函数的同一绘图之间的比较。

op <- par(mfrow = c(2,1))
set.seed(1)
rr <- rnorm(5)
plot(rr, 1:5, frame.plot = TRUE)
plot(rr, 1:5, axes = FALSE, frame.plot = TRUE)
my.at <- round(rr,4)
axis(1, at = my.at, labels = my.at)

enter image description here

关于r - 绘图:轴上的小数点精度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17535706/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com