0

Using Python, I try to create a plot that has one x-axis and two y-axes. This is not a problem, but somehow during looping only the curves in the host plot and the last curve in the par plot are shown. Below is my code.

files = ['File-01', 'File-02', 'File-03']
p = [None]*len(files)
d = [None]*len(files)   

for i in xrange(len(files)):
    p[i] = Read(files[i])
    d[i] = Process(p[i])
    d[i].PlotI()

#some other coding

def PlotI(self):        
    plt.figure('ParameterA and parameterB vs time')
    host = plt.subplot()
    par = host.twinx()
    host.plot(self.time, self.A, label = self.file,
              c = self.colour, linewidth =2, linestyle = '-')
    par.plot(self.time_hrs, self.B, label = self.file,
             c = self.colour, linewidth = 2, linestyle = ':')
    host.set_xlabel('Time [-]')
    host.set_ylabel('A [-]')
    par.set_ylabel('B [-]')
    plt.legend(loc = 'best', frameon=0)

So what I try to do is, plot for n different files parameter A and B (both vectors) in the same graph. Where the x-axis is shared and both parameters have their own y-axis.
Hopefully you can help me out!

Mariska
  • 1
  • 2

0 Answers0