user18143
user18143

Reputation: 171

Inverting a single axis plot in R

I plotted a single column in R with the code below

plot(datanew$cap)

But what I actually need is that the points on the x-axis should be on the y-axis while the point on the y-axis should be the x-axis. If anyone has an idea on how I can do this, I will greatly apreciate.

Upvotes: 0

Views: 121

Answers (1)

fotNelton
fotNelton

Reputation: 3894

Plotting via

plot(datanew$cap)

is basically the same as

plot(seq(length(datanew$cap)), datanew$cap)

You can use this to your advantage by swapping the arguments (or specifiying x- and y-coordinates explicitly):

plot(x=datanew$cap, y=seq(length(datanew$cap)))

Upvotes: 2

Related Questions