Edinburgh-Genome-Foundry / DnaFeaturesViewer

:eye: Python library to plot DNA sequence features (e.g. from Genbank files)
https://edinburgh-genome-foundry.github.io/DnaFeaturesViewer/
MIT License
584 stars 90 forks source link

Broken Axis #58

Open lisiarend opened 3 years ago

lisiarend commented 3 years ago

Hey, first of all I want to thank you for the very nice package. I have a question or maybe an extension to your package.

I am visualizing the exon/intron structure of a gene. Actually, the introns are very big compared to the exons and therefore there is a lot of free space between the interesting exon parts. Is there a way to rescale the parts where no GraphicFeature is defined.

I attached a file where one can see that the colored parts (exons) are very small and there is a lot of space between them. I wanted to ask if there is a way to reduce the white space between the exons.

Kind regards, Lisi

bildschirmfoto_2021-04-26_um_10 48 59
Zulko commented 3 years ago

There is no way right now but that's a nice suggestion, you could imagine a squash_empty_regions_over=5000 which would re-coordinate the features while keeping the x tick labels correct, but it would require some effort to design and implement I guess.

In the meantime my recommendation would be to plot the two exons on two different subplots:

import matplotlib.pyplot as plt
ax1, ax2  = plt.subplots(1, 2)
record.crop((start1, end1)).plot(ax1)
record.crop((start2, end2)).plot(ax1)

Then there must be a way to make this look like a broken axis, but this is very hackish in Matplotlib