Reputation: 159
I have a dataframe with a time column and several serial number columns. I am trying to plot the serial number columns vs time. I am unsure of how to do this being as there are a variable number of serial numbers that could be in the dataframe.
400602902 Time 400621787 400621434 400619512
0 11066 0.1 10518 10948 10795
1 13716 0.2 13206 13688 13420
2 15995 0.3 15194 16367 16091
3 19109 0.4 17485 19128 18949
4 20298 0.5 19811 20296 20298
My internet research has brought me to the below code but I am struggling with how to plot multiple lines when i do not know exactly how many there will be.
graphingWindow = tk.Tk()
graphingWindow.title('Filmcool Siganture Charts')
graphingWindow.minsize(width=600,height=800)
#Depth Plot
figure1 = plt.Figure(figsize=(5,4), dpi=100)
ax1 = figure1.add_subplot(111)
line1 = FigureCanvasTkAgg(figure1, graphingWindow)
line1.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH)
depthDF.plot(kind='line', legend=True, ax=ax1, color='r',marker='o', fontsize=10)
ax1.set_title('EDM Depth Vs. Time')
Upvotes: 0
Views: 578
Reputation: 585
Using some of your data, here's a way to chart each column against Time
using matplotlib
:
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
df = pd.DataFrame({"Time":[0.1,0.2,0.3],"400602902":[11066, 13716, 15995],"400621787":[10518, 13206, 15194]})
x = df.drop("Time", axis=1)
for col in x:
plt.plot( 'Time', col, data=df, marker='o', markerfacecolor='blue', markersize=12, color='skyblue', linewidth=4)
plt.legend()
Result:
Upvotes: 1