Single Array & Data Plotting with it
<p>The data I have is printed in a .txt file format and has breaks in between readings, its just one really long line. Each data point is a 16 second average of the z-component of the magnetic field of an incoming particle field. This is currently the code I have typed to ascribe the variable name to the file</p>

<pre><code>Bz = np.loadtxt(r'C:\Users\Schmidt\Desktop\Project\Data\ACE\MAG\ACE_MAG_Data.txt', dtype = str)
</code></pre>

<p>and that works fine, but when I ask to print Bz I get </p>

<pre><code>[["b'-1.3695e+01'" "b'-1.3481e+01'"]
["b'-1.3804e+01'" "b'-1.3485e+01'"]
["b'-1.3704e+01'" "b'-1.3437e+01'"]
..., 
["b'1.6371e+00'" "b'6.2744e-01'"]
["b'1.6171e+00'" "b'6.1338e-01'"]
["b'1.4028e+00'" "b'3.2874e-01'"]]
</code></pre>

<p>What my problem is how did that "b" get there in the first place and how do I tell python that each data point is an individual point instead of pairs like it has it now.</p>

<p><a href="https://www.dropbox.com/s/cev5stizmzu4w07/ACE_MAG_Data.txt?dl=0" rel="nofollow">This is the link to the file if you need to see.</a> Just remember to remove the words and the file should act appropriately.</p>

<p>numpy is loading your data as bytes, and marking them as such, with the b character. I tried the following:</p>

<pre><code>data = np.loadtxt("ACE_MAG_Data.txt", dtype=bytes).astype(float)
</code></pre>

<p>And it converts everything to floats instead:</p>

<pre><code>&gt;&gt;&gt; data
array([[-13.695  , -13.481  ],
       [-13.804  , -13.485  ],
       [-13.704  , -13.437  ],
       ..., 
       [  1.6371 ,   0.62744],
       [  1.6171 ,   0.61338],
       [  1.4028 ,   0.32874]])
</code></pre>

<p>You mention that these are individual points, not pairs. If you had saved them as points in the file, one per line, numpy wouldn't assume these are pairs - I would too :)</p>

<p>However:</p>

<pre><code>singles = [point for pair in data for point in pair]
</code></pre>

<p>Will convert it to a list of single points.</p>

python matplotlib plot