[英]R: change x-axis direction
plot(runif(12))
creates a plot with x-axis numbers: 1, 2, 3, 4 and 5. In this way, the positive direction is left-to-right. plot(runif(12))
创建一个x轴编号为1、2、3、4和5的图形。这样,正方向从左到右。
It is possible to define the possitive direction from right to left?. 可以定义从右到左的正方向。
Something like plot(runif(12), xAxisDirection='right-to-left')
像plot(runif(12), xAxisDirection='right-to-left')
You can reverse the range and pass it to xlim
parameter in plot 您可以反转范围并将其传递给xlim
参数
x <- runif(12)
plot(x, xlim=rev(range(x)))
You could pass the labels and plot the x axis separately: 您可以传递标签并分别绘制x轴:
set.seed(123)
v = runif(12)
lab = seq(1, length(v), by = 2)
lab = lab[order(-lab)]
lab.at = length(v) - lab + 1
plot(v, xaxt = "n")
axis(1, at = lab.at, labels = lab)
For other data (eg meaningful x labels) you could create an artificial x value that is plotted (eg x.plot = min(x) - x
) to sort the data while you label the x axis with values of your x variable. 对于其他数据(例如有意义的x标签),您可以创建一个人工绘制的x值(例如x.plot = min(x) - x
)以对数据进行排序,同时使用x变量的值标记x轴。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.