I am trying to write a program that takes columns from an excel file and plots them. The plot has multiple axes, and is data from a fermentation. I have had help with the code for the plot, but I cannot get it to work with the data. Is python reading the columns as strings? Here comes the code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# with the given sample data
data = {'Time': [0, 1, 2, 3], 'Temp': [28.05, 29.0, 28.65, 27.04], 'Agit': [400, 397, 402, 430], 'DO': [71.0, 5.0, 5.5, 2.0], 'pH': [5.5, 5.2, 4.9, 4.75], 'GasFlow': [1.0, 1.02, 1.01, 1.05]}
df = pd.DataFrame(data)
# insert the name of the column as a string in brackets
Time = list(df['Time'])
pH = list(df['pH'])
DO = list(df['DO'])
Agit = list(df['Agit'])
GasFlow = list(df['GasFlow'])
Temp = list(df['Temp'])
In [5]:
#%% Writing data
time = [Time] # Hours
temperature = [Temp] # dC
agitation = [Agit] # rpm
DO = [DO] # %
pH = [pH] # pH
gas_flow = [GasFlow] #vvm
# Plot the data
fig, host = plt.subplots(figsize=(8,5)) # (width, height) in inches
p1, = host.plot(time, temperature, color=color1, label="Temperature")
And the error:
ValueError Traceback (most recent call last)
<ipython-input-5-97e016dc1996> in <module>
72 # Plot the data
73
---> 74 p1, = host.plot(time, temperature, color=color1, label="Temperature")
75
76 p2, = par1.plot(time, agitation, color=color2, label="Agitation")
ValueError: too many values to unpack (expected 1)