I have a matrix which can easily be displayed as an image in R with image(). The trouble is the way this matrix is oriented: the origin is intended to be in the lower left corner of the matrix. As a consequence, when the matrix is plotted with the image() function, some of the axis appear backwards (I'm working with large, spatial climate data).
When using the imshow() function from Python's matplotlib, I'm able to pass the option origin = 'lower' with the function. Does R have a similar option or a function that could easily perform the transformation I need? I can't imagine that I'm the only person with this problem.
If you by origin mean the first element of the matrix you're already good. Just flip it with t() if you want to turn it the other way. If you want to flip it to the way you would look at it in matrix form, i.e. first element in top left corner, flip the first dimension like in the second example.
a <- matrix(1:16, 4, 4)
image(t(a))
image(t(a[4:1,]))

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With