In my code I have something like:
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot()
...
fmtstr = '{:<15}{:<15}{:<15}\n{:<15}{:<15}{:<15}\n{:<15}{:<15}{:<15}\n{:<15}{:<15}{:<15}'
ntext = fmtstr.format(' ', 'tot', 'unique',
'in ', str(len(seqzs[fp])), str(len(seqzsSet[fp])),
'std ', str(len(seqzs[std])), str(len(seqzsSet[std])),
'shrd', '', str(len(dRTShrd)))
ax.text(0.03, 0.8, ntext, transform=ax.transAxes)
print(ntext)
...
plt.savefig(os.path.join(outDir, oname))
The formatted text ntext
looks good when print
ed:
tot unique
in 6826 3837
std 24773 11376
shrd 3220
How do I get it right in the plot? (The widths of the numbers change with every plot so I need a constant formatter)