Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.
X = np.array([[-1, 1], [-2,-1], [-3, -2], [1, 1], [2, 1], [3, 2]])
plt.plot(X)
plt.show()

If I plot this the first element in each list is Y and the second is X. So for [-1, 1], -1 is Y and 1 is X. Why is this the default and what's the best way to change it?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This is the default because (from the help):

If *x* and/or *y* is 2-dimensional, then the corresponding columns
will be plotted.

You could do, instead,

import numpy as np
import matplotlib.pyplot as plt
X = np.array([[-1, 1], [-2,-1], [-3, -2], [1, 1], [2, 1], [3, 2]])
plt.plot(X.T[0], X.T[1])
plt.show()

which starts at (-1,1) and winds up at (3,2).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.