Error with twinx: 'PlotAccessor' object has no attribute 'twinx'

162 Views Asked by At

I'm using a for loop with a list of variables to create multiple plots against one variable each plot has an item in the list iterated in the for loop against the variable "PUMP FAILURE (1 or 0)"

ATTEMPT

ListOfVariables = ['Volumetric Flow Meter 1',  'Volumetric Flow Meter 2',  'Pump Speed (RPM)', 'Pump Torque',   'Ambient Temperature',  'Horse Power',  'Pump Efficiency']

for item in ListOfVariables:
    first_axis = dataframe_raw[item].plot
    second_axis = first_axis.twinx()
    second_axis.plot(dataframe_raw['PUMP FAILURE (1or 0)'], color='teal')
    plt.title(item)
    plt.show()

ERROR

      3 for item in ListOfVariables:
      4     first_axis = dataframe_raw[item].plot
----> 5     second_axis = first_axis.twinx()
      6     second_axis.plot(dataframe_raw['PUMP FAILURE (1or 0)'], color='teal')
      7     plt.title(item)

AttributeError: 'PlotAccessor' object has no attribute 'twinx'
1

There are 1 best solutions below

0
On

Line 4 needs () after .plot. (I know this because I just had to correct the same mistake.)