Extract header names from a CSV and use it to plot against each other in Python?
<p>I am pretty new to python and coding in general. I have this code so far.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>import numpy as np
import matplotlib.pyplot as plt

data = np.loadtxt('data.csv', delimiter=',', skiprows=1)

mSec = data[:,0]
Airspeed = data[:,10]
AS_Cmd = data[:,25]
airspeed = data[:,3]

plt.rc('xtick', labelsize=25) #increase xaxis tick size
plt.rc('ytick', labelsize=25) #increase yaxis tick size

fig, ax = plt.subplots(figsize=(40,40), edgecolor='b')
ax.patch.set_facecolor('white')


ax.plot(mSec, Airspeed, label='Ground speed [m/s]')
ax.plot(mSec, AS_Cmd, label='Voltage [V]')

plt.legend(loc='best',prop={'size':20})
fig.savefig('trans2.png', dpi=(200), bbox_inches='tight') #borderless on save</code></pre>
</div>
</div>
</p>

<p>However, I don't want to individually read every data column there is. I want to be able to load a csv file and have it read out all column names, then asks the users what you want for your x-axis and y-axis and plots that graph. The csv file format is:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>time(s),speed(mph),heading,bvoltage(v)
20,30,50,10
25,45,50,10
30,50,55,9</code></pre>
</div>
</div>
</p>

<p>Here is my attempt at the code but I am missing a lot of information:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>import numpy as np
import matplotlib.pyplot as plt



data = np.loadtxt('data.csv', delimiter=',')
## names = where I will store the column names

white True:
    ## display names to user
    print ('Pick your x-axis')
    xaxis = input()
    print ('Pick your y-axis')
    yaxis1 = input()
    print('pick a 2nd y-axis or enter none')
    yaxis2 = input()
        if input()= 'none'
        break;
        else continue
    #plot xaxis vs yaxis vs 2nd yaxis</code></pre>
</div>
</div>
</p>

<p>I understand the loop is not correct. I don't want anyone to correct me on that I will figure it out myself, however, I would like a way to access those values from the CSV file so that I can use it in that method.</p>

<p>If you don't mind using/installing another module then <strong>pandas</strong> should do it. </p>

python matplotlib