I have data that looks like:
sp sample_name homo_anc het homo_dev Heterozygozity
1 BF RSFV1M 835314771 1857148 2106125 0.2212792
2 BF RSFV1N 832516832 3049895 1576519 0.3643218
3 BF RSFV1O 834367309 2651230 1762650 0.3160813
4 BF RSFV1P 828847720 2902735 1604046 0.3483194
5 BF RSFV1Q 835338722 2261941 1948946 0.2694231
...
21 WBM RSFV1I 833924008 3378924 2285658 0.4024499
22 WBM RSFV1J 833263882 3324019 2333676 0.3962252
23 WBM RSFV1L 828667189 3354676 2266616 0.4021003
and am trying to plot as a geom_dotplot using:
p <- ggplot(het, aes(x=sp, y=Heterozygozity, fill=sp, colour=sp))+
geom_dotplot(binaxis = "y", binwidth = 0.002, stackdir = "center", dotsize=7, binpositions="bygroup") +
# Custom the theme:
theme_bw() +
theme(
legend.position="none",
panel.border = element_blank(),
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
axis.title.x=element_blank(),
axis.ticks.x=element_blank()
)
but there's too much space between the two categories BF and WBM plus I need the order the show up in the x axis to be the same as in the data. I tried to add coord_fixed(ratio = 3)
but it just smashes the plot on the horizontal, and I tried to fix the order by doing aes(x=sort(sp)...
but It only reorder the labels without moving the data points.