когда вы используете matrix (), он заполняет матрицу столбцом, поэтому проверяете ваши первые 199 значений, все с x2 == 1,
all(lr.pred$predicted[1:199] == pl.pred.mtrx[,1])
Когда вы строите эту матрицу с помощью image ()вы фактически транспонируете матрицу и наносите цвета, вы можете попробовать это так:
image(matrix(1:18,ncol=2))
Таким образом, на вашем графике xaxis равен x1, а yaxis равен x2, и мы можем добавить метки оси, подавив отметки.
# we place it at 1,10,20..100
TICKS = c(1,10*(1:10))
image(pl.pred.mtrx,xlab="x1",ylab="x2",xaxt="n",yaxt="n")
# position of your ticks is the num over the length
axis(side = 1, at = which(x_sample.lr %in% TICKS)/nrow(pl.pred.mtrx),labels = TICKS)
axis(side = 2, at = which(x_sample.lr %in% TICKS)/ncol(pl.pred.mtrx),labels = TICKS)
![enter image description here](https://i.stack.imgur.com/exJI2.png)
Я не знаю простого способа добавить цветовую легенду. Поэтому я предлагаю использовать поля:
library(fields)
# in this case we know how x and y will run.. with respect to matrix z
# in other situations, this will depend on how you construct z
DA = list(x=x_sample.lr,y=x_sample.lr,z=pl.pred.mtrx)
image.plot(DA,col=hcl.colors(12, "YlOrRd", rev = TRUE))
![enter image description here](https://i.stack.imgur.com/CMUV8.png)