user4791235
user4791235

Reputation:

Plot() command to move x-axis on top of the plot

I'm trying to move the x-axis labeling and tick marks above the plot on top. Here's my code.

ucsplot <- plot(ucs, depth, main= "Depth vs. UCS", xlab = "UCS (psi)", ylab="Depth (ft)", type="l", col="blue", xlim=c(0, max(dfplot[,3]+5000)), ylim = rev(range(depth)))
ucsplot

How do I get the x-axis labeling and tick marks to appear only on top, instead of the bottom? Also, how do I get the title to not sit right on top of the numbers right above the tick marks? Also, how do I get the chart to start not offset a little bit to the right? As in the zero and starting numbers are in the corners of the plot and not offset.

Upvotes: 2

Views: 976

Answers (1)

MKR
MKR

Reputation: 20085

Seems the OP is looking for a plot where x-axis is at top. The data has not been provided by OP. Hence using a sample dataframe, solution can be displayed as:

df <- data.frame(a = 1:10, b = 41:50)

plot(a ~ b, data = df, axes = FALSE, xlab = NA, ylab = NA)
axis(side = 2, las = 1)
axis(side = 3, las = 1) 

enter image description here

Upvotes: 3

Related Questions