Reputation: 934
I have the following code that simply imports temperature data, assigns variables and plots 3 lines on the same figure. However, the x-axis values are in milliseconds (undesirable) and I would like to convert them to hours... any idea how to do this? Here is my code:
def plot_temp(file_name, name):
df = pd.DataFrame.from_csv(file_name, index_col = None)
w = df['Time']
x = df['Input 1']
y = df['Input 2']
z = df['Input 3']
figsize(6,4)
plot(w,x, label = "Top_sensor")
plot(w,y, label = "Mid_sensor")
plot(w,z, label = 'Bot_sensor')
title('Temperature log' + name)
xlabel('Time(ms)')
ylabel('Temperature (K)')
legend()
Upvotes: 0
Views: 70
Reputation: 7194
The easiest way of doing this would be to convert the array w
to hours before plotting it.
Just take
w = df['Time']
w /= 3600000 # Convert milliseconds to hours
To change the initial time of the xaxis to a certain value (say 12 hours) then you could do:
initial_time = 12.0
w += initial_time - min(w)
Upvotes: 2