Plot: decimal precision on axis

I have two data columns, X and Y , with each record having 4 data places after the decimal number in both vectors.

When I make a simple graph with plot(x,y) , the axes have data shown accurate to 2 decimal places. How to change this to accuracy at 4 decimal points on both axes?

I added the example data below ( inputData ), which I built using 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") 

I would like to reproduce an example of this dataset, as well as part of the proposed answer.

 > inputData XY 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

+6
source share
1 answer

One axis parameter is used to set up shortcuts. Here is a comparison between the same plot using the default plot axis and using the axis function.

 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

+5
source

Source: https://habr.com/ru/post/948975/


All Articles