EDITED
What I am starting with : I have multiple .xyz files for profiles ranging from
1982_1_Final.xyz - 1982_54_Final.xyz and such from 1982-2012
with Elevation/depth and Distance data columns to be able to plot horizontal profiles.
The Aim : I want to compare let say profile 25 for all years from 1982 until 2012,
so 1982_25_Final.xyz, 1983_25_Final.xyz, 1984_25_Final.xyz..... 2012_25_Final.xyz
What I have so far :
import os
import pandas as pd
import matplotlib.pyplot as plt
path = 'C:/Clayton/lines/profiles_aufmod'
os.chdir(path)
print(os.getcwd())
# Initiate figure
NUM_COLORS = 30
linestyle = ['solid', 'dashed', 'dashdot', 'dotted']
NUM_STYLES = len(linestyle)
cm = plt.get_cmap('gist_rainbow')
fig = plt.figure()
ax = fig.add_subplot(111)
for directory_2, subdir_2, file_2 in os.walk(path):
for ind, filename_2 in enumerate(file_2, 1):
if filename_2.endswith("25_Final.xyz"):
os.chdir(directory_2)
Profile_raw_2 = pd.read_csv(
filename_2, delimiter=',', names=["lat", "lon", "prof", "elev","dist"])
lines = ax.plot(Profile_raw_2.iloc[:, 4], Profile_raw_2.iloc[:, 3], label=filename_2[0:29])
for i in range(NUM_COLORS):
lines[0].set_color(cm(i // NUM_STYLES * float(NUM_STYLES) / NUM_COLORS))
lines[0].set_linestyle(linestyle[i % NUM_STYLES])
os.chdir(path)
plt.show()
Problems I am facing : The nesting of the for loop is somehow wrong and I get all plots in one color and one linestyle, I cannot figure out the right order for the for loops here to get the desired output.
What I need help with :
- Nesting the for loop in the right order
- Making sure the colors are different for each year.
- How to change the colormap before hand to possibly get a sequential type which is good to indicate a yearly changing data.
- Any recommendations for such a plot?
Thank you in advance and sorry if there are some obvious mistakes, I am fairly new to python.