Open Ale-Rossi opened 2 years ago
Thanks for bringing attention to this. I believe a solution would not be trivial, as the core algorithm that works on one plot and places the labels need to be made aware of the true size of the plot.
A workaround is to set labels_spacing
big enough to put each label on its own line:
graphic_records[0].labels_spacing = 100
fig, axes = plt.subplots(len(graphic_records), sharex=True, figsize=(10,5))
for record, ax in zip(graphic_records, axes):
record.plot(ax=ax, annotate_inline=False, elevate_outline_annotations=False)
What happens when you plot 2 sequences in a figure with share_x is:
share_x
, this can squeeze the upper plot, and cause the labels to overlap.If I remember correctly there is an easy fix which is to use x_lim
so that all plots get plotted with the right x scale from the start:
record_1.plot(ax=ax[0], xlim=[0, 17000])
record_2.plot(ax=ax[1], xlim=[0, 17000])
I tried to use plt.subplots to plot multiple sequences in a single figure, using the option sharex=True in order to keep the same scale for all the sequences. This means that shorter sequences get "squeezed" when drawn, and labels are closer together than they would be if they didn't share the x axis with the longer sequences. This is not taken into account and labels end up overlapping.
Thank you for your attention and thank you for this package, it is very well made and I really like the approach to coding shown in the documentation.
Please find attached the code and data used to generate this example.
overlapping_labels.zip