SverigeKile
SverigeKile

Reputation: 3

R - plotted data points are indistinguishable

W = c(20000, 5000, 3000, 8, 2, 0.5)
BMR = c(19000, 12000, 960, 86, 30, 10)
BMRPlot <- plot(W, BMR, main='Graph 2', cex=1.25, pch=21, bg='blue', lwd=1)

The above is the data I am trying to plot, however as you can probably tell the final data points once plotted appear to be indistinguishable as they are so close together. What could I add to my line of code that would change the view of this so that all points could be visible?

Upvotes: 0

Views: 60

Answers (1)

jrdnmdhl
jrdnmdhl

Reputation: 1955

In a situation like this, you more or less have to use a transformation to make all the points visible. Otherwise, the points would have to be incredibly small not to overlap, and then you wouldn't be able to see them.

A log transformation of x and y seems to work here.

logW = log(c(20000, 5000, 3000, 8, 2, 0.5))
logBMR = log(c(19000, 12000, 960, 86, 30, 10))
BMRPlot <- plot(logW, logBMR, main='Graph 2', cex=1.25, pch=21, bg='blue', lwd=1)

enter image description here

As noted by commenter below, you can do the log-transform within the plot statement if you want your tick values to be untransformed:

W = c(20000, 5000, 3000, 8, 2, 0.5)
BMR = c(19000, 12000, 960, 86, 30, 10)
BMRPlot <- plot(W, BMR, main='Graph 2', cex=1.25, pch=21, bg='blue', lwd=1, log="xy")

enter image description here

Upvotes: 0

Related Questions