Skip to content

Commit

Permalink
better legend labels
Browse files Browse the repository at this point in the history
  • Loading branch information
RaverJay committed Nov 4, 2020
1 parent da05f65 commit e2484b3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions fastcov.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def parse_bam_files(bam_files, chunk, cov_data, pool, process_results):

def worker_get_coverage_ref_name(bam_file: str, chunk: BamFileChunk):

log(f'{os.getpid()} working on {bam_file} ...')
log(f'Process {os.getpid()} working on {bam_file} ...')
start_time = time.time()
with pysam.AlignmentFile(bam_file, 'rb') as pysam_bamfile:

Expand Down Expand Up @@ -152,7 +152,7 @@ def plot(args, chunk, data) -> str:
# plot it
sns.set(style="whitegrid")
fig, ax = plt.subplots(figsize=(20, 9))
sns.lineplot(data=data, linewidth=1.5, dashes=False, alpha=0.8)
sns.lineplot(data=data, linewidth=1.5, dashes=False, alpha=0.8, legend=False)

# formatting and annotation
ydn, yup = plt.ylim()
Expand Down Expand Up @@ -180,6 +180,9 @@ def plot(args, chunk, data) -> str:
plt.xticks(locs, [f'{int(pos):,}' for pos in locs])
plt.xlim(xlims)

short_names = [name.rsplit('/', 1)[-1].rstrip('.bam') for name in data.columns]
plt.legend(labels=short_names)

# save figure
plt.savefig(output_name, bbox_inches='tight')
return output_name
Expand Down

0 comments on commit e2484b3

Please sign in to comment.