emmanuelparadis / pegas

Population and Evolutionary Genetics Analysis System
GNU General Public License v2.0
27 stars 10 forks source link

Plotting labels next to haplotypes, not onto them #80

Closed naurasd closed 11 months ago

naurasd commented 11 months ago

Hey,

Is there any way to plot the haplotype labels next to the haplotypes instead of in the center of them? As you can see below, the labelling doesnt look nice when its being placed inside the haplotypes: grafik

My solution at the moment is to plot with labels=F and then add the labels next to the haplotypes with another program outside of R.

Cheers Nauras

emmanuelparadis commented 11 months ago

Hi Nauras, Try this:

xy <- plot(net, labels = FALSE, .......... # other arguments as necessary
text(xy$xx, xy$yy + 1, attr(net, "labels"))

You will certainly need to try several times to find the correct value to put in place of + 1. Maybe something like this could be nice:

my <- mean(xy$xx)
Yoffset <- ifelse(xy$yy >= my, 1, -1)
text(xy$xx, xy$yy + Yoffset, attr(net, "labels"))

and you cannot define Xoffset in the same way.

emmanuelparadis commented 11 months ago

Another possibility would be to change the colour of the labels. But I just found out that this not possible directly: I'll fix that a future release. However, you can do it using the solution I just suggested above using text. Maybe "grey" would like better than the default black. Anyway, offsetting the labels is surely preferable.

naurasd commented 11 months ago

Thanks for the offseeting idea, I made it work. Takes some fiddling around but is good enough ;-)

Thanks again for the quick help.