Plotting secondary Y-axis using Panda?
<p>My current code takes a list from a csv file and lists the header for the user to pick from so it can plot.</p>

<pre><code>import pandas as pd

df = pd.DataFrame.from_csv('log40a.csv',index_col=False)

from collections import OrderedDict
headings = OrderedDict(enumerate(df,1))
for num, heading in headings.items():
    print("{}) {}".format(num, heading))

print ('Select X-Axis')
xaxis = int(input())

print ('Select Y-Axis')
yaxis = int(input())

df.plot(x= headings[xaxis], y= headings[yaxis])
</code></pre>

<p>My first question. How do I add a secondary Y axis. I know with matplotlib I first create a figure and then plot the first yaxis with the xaxis and then do the same thing to the 2nd yaxis. However, I am not sure how it is done in pandas. Is it similar?</p>

<p>I tried using matplotlib to do it but it gave me an error:</p>

<pre><code>fig1 = plt.figure(figsize= (10,10))
ax = fig1.add_subplot(211)
ax.plot(headings[xaxis], headings[yaxis], label='Alt(m)', color = 'r')
ax.plot(headings[xaxis], headings[yaxis1], label='AS_Cmd', color = 'blue')
</code></pre>

<p>Error:</p>

<pre><code>ValueError: Unrecognized character a in format string
</code></pre>

<p>You need to create an array with the column names that you want plotted on the y axis. </p>

<p>An example if you delimite the y columns with a ','</p>

<pre><code>df.plot(x= headings[xaxis], y=headings[yaxis.split(",")], figsize=(15, 10))
</code></pre>

<p>To run it you will need to change your input method, so that it is an array rather then a string. </p>

python pandas