plot: Decimal point accuracy on the axis
Asked Answered
S

1

6

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

When I make the simple plot with plot(x,y) the axes have the data shown up to 2 decimal point accuracy. How do I change this to a 4 decimal point accuracy, on both axes?

I've added the example data below (inputData), that I have plotted 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 a reproducible example on this above dataset, as well as part of the suggested answer.

> 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

Seaboard answered 8/7, 2013 at 20:46 Comment(3)
Please add some data , and your R code that you have tried.Holism
Use dput(head(inputData) and add it to your question to provide a reproducible example.Holism
I would like a reproducible example on this above dataset, as well as part of the suggested answer.Seaboard
H
6

One option is use axis to customize your labels. Here a comparaion between the same plot using the default axis of plot and using 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

Holism answered 8/7, 2013 at 21:16 Comment(2)
the scale on the x-axis isn't exactly what I want as only the ticks where the points exist are numbered/labeled and there is no uniformly spaced scale/ticks which absolutely does not help to analyze the plot.Seaboard
@PraneethVepakomma You can't do better with basic plot. What do you expect to get? your points are not uniformly scaled. If you want to have uniformily scaled , with 4 points precision, you will add some zeos to each tick , 33.6000,33.6500,.. since are just virtual points. Hope it is clear. (No need to downvote)Holism

© 2022 - 2024 — McMap. All rights reserved.