I'm new to coding. I've been tasked to plot a graph using data from multiple data frame. The number of data frames to be used is indefinite (n). The same X & Y-axis will be plotted throughout the data frames. Can you please kindly guide me through this? My mentor has wrote the code for the first part(extracting the data from the track files, and then importing them to Python). I just need to plot the graph.
import subprocess
import pandas as pd
import os
import matplotlib.pyplot as plt
#folder where the .tracks files are
main_path = r"N:\Projects\Misc\Joint geometry analysis"
file_list = [each for each in os.listdir(main_path) if each.endswith('.tracks')]
print (file_list)
opera_app = r"readtrac.exe" #utility for converting track files to ascii fwf
os.chdir( main_path )
#put readtrac.exe and library files into the working directory
utility_path = r"C:\Program Files\Vector Fields\Opera 15R3 x64\bin"
utilities = [opera_app, "libifcoremd.dll", "libmmd.dll"]
for u in utilities:
f = os.path.join(main_path,u)
if not os.path.exists(f):
s = os.path.join(utility_path,u)
print ( "copy " + s + " " + f)
status = subprocess.check_output(['copy', s, f], shell=True)
print("status: ", status.decode('utf-8'))
header = 9 #line where the columns start
widths = [6,16,16,16,16,16,16] # format of the .fwf file - column widths
df = [] #list of data frames
for f in file_list:
trac_name_ip = f
trac_name_op = trac_name_ip[:-6] + "fwf"
print ('converting a track file called ' + trac_name_ip + ' to an ascii fwf file called ' + trac_name_op)
subprocess.run([opera_app, trac_name_ip, 'B', trac_name_op]) # NB this won't overwrite a .fwf file
df.append(pd.read_fwf(trac_name_op, header = header, widths = widths)) #read the fwf file into a pandas dataframe
df[0].head()
I know how to plot a basic graph but I don't know what commands I should use to plot a graph with indefinite amount of data frames - lets say I want to plot df[['XP', 'ZP']]
of each data frame onto one plot, what should I do?
Ideally I want a XY scatter plot, with the name of the each individual dataframes as the name of the series in a legend.
Thanks