an array from genfromtxt is being passed as a sequence?
<p>I have a list of coordinates and their respective error values in the shape:</p>

<pre><code># Graph from standard correlation, page 1
1.197   0.1838  -0.03504    0.07802 +-0.006464  +0.004201
1.290   0.2072  -0.04241    0.05380 +-0.005833  +0.008101
</code></pre>

<p>where the columns denote <code>x,y,lefterror,righterror,buttomerror,toperror</code>I load the file as <code>error=np.genfromtxt("standard correlation.1",skip_header=1)</code> and finally I try to graph this as</p>

<pre><code>xerr=error[:,2:4]
yerr=error[:,4:]
x=error[:,0]
y=error[:,1]
plt.errorbar(x,y,xerr=xerr,yerr=yerr,fmt='')
</code></pre>

<p>Which yells a <code>ValueError: setting an array element with a sequence.</code>when I try to run it, I understand this error is given when you're passing an object such a a list to an argument that's expecting a numpy array object, I am clueless as to how I should fix this problem, as np.genfromtxt should always return an ndarray.</p>

<p>Thanks for your help.</p>

<p><strong>Edit:</strong> I changed the file to remove the '+' character, as reading '+-' would yield NaN values in the bottom error column, but I still get the same error.  </p>

<p>Thanks to hpaulj I noticed that the error bars' shape was (30,2), however <code>plt.errobar()</code> expects error arrarys in the shape (2,n), as python usually transposes matrices in similar operations and automatically avoids this problem I figured it would also do it, but I decided to change lines the following way:</p>

<pre><code>xerr=error[:,2:4]
yerr=error[:,4:]
</code></pre>

<p>into</p>

<pre><code>xerr=np.transpose(error[:,2:4])
yerr=np.transpose(error[:,4:])
</code></pre>

<p>which made the script run properly, although I still don't understand why the previous code gave me such an error, if anyone can help me clear that up I'll appreciate it.</p>

python arrays numpy matplotlib errorbar