Matplotlib: two plots on the same axes with different left right scales
<p>I am trying to use this example: <a href="http://matplotlib.org/examples/api/two_scales.html#api-two-scales" rel="nofollow">http://matplotlib.org/examples/api/two_scales.html#api-two-scales</a> 
with my own dataset as shown below:</p>

<pre><code>import sys
import numpy as np
import matplotlib.pyplot as plt
print sys.argv
logfile = sys.argv[1]
data = []
other_data =[]
with open(logfile,'rb') as f:
    for line in f:
        a = line.split(',')
        print a
        data.append(a[1])
        other_data.append(a[2][:-1])
print other_data
x = np.arange(0,len(data))
fig,ax1 = plt.subplots()
ax1.plot(x,np.arange(data))

ax2 = ax1.twinx()
ax2.plot(x,np.arange(other_data))
plt.show()
</code></pre>

<p>However, I keep getting this error: </p>

<pre><code>'Traceback (most recent call last):
  File "share/chart.py", line 17, in &lt;module&gt;
    ax1.plot(x,np.arange(data))
TypeError: unsupported operand type(s) for -: 'list' and 'int'
</code></pre>

<p>I think I am using the twinx command correctly but apparently not. How can I do this?</p>