Issue
I'm using pyplot
with matplotlib
, and I would like to display some data as an image. When I use imshow()
the data is flipped from the way I want to view it. How would I switch the x and y axes, either with imshow()
or to the numpy
array before I send it to imshow()
?
(i.e. I want the horizontal axis to be vertical)
I've tried using origin='upper'
and origin='lower'
in the imshow()
command, but that just reverses one axis instead of switching them around
I've also tried using reshape
on the data, but the order gets all messed up
Solution
To close out the question-
You need to transpose the numpy array before passing it to matplotlib
:
>>> a
array([[0, 1],
[2, 3]])
>>> a=a.T
>>> a
array([[0, 2],
[1, 3]])
So using plt
it should simply be:
plt.imshow(a.T)
Answered By - Daniel
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.