I have a rather simple problem but something that's had me stumped for 2days. I need to plot 2+ files. Each file will need to be plotted on a total of 25 plots but must be plotted on the same set of axes. (ie. if theres 2 files I need 25 plots with 2 lines on each plot).
I have this sudo code which generates 50 plots (One line for each)...which is wrong
with open(bamlist, 'r') as bamlist:
for bam in bamlist: #Opens the 2 files
'Generate data Here'
dataframe = []
for line in data:
line = line.split("\t")
dataframe.append(line[0:4:1])
df = pd.DataFrame(dataframe, columns=['Chromosome', 'Position', 'N', 'BaseCount'])
grouped_df = df.groupby('Chromosome') #groups dataframe into the required 25plots
for df in grouped_df:
density_data = 'Get density data from df'
f, ax = plt.subplots()
sns.kdeplot(density_data, ax=ax, linewidth=1)
pp.savefig()
pp.close()
Is there a way to revert back to the initial set of axis the 2nd time the for loop is entered so that I will get 2 lines per plot with 25plots (as opposed to 50)?