How can I choose which panel(s) in a facet_plot graph are highlighted/labelled?

65 Views Asked by At

I want to visualise a tree in ggtree with clades highlighted and genera labelled. This is working fine. I also want to add a dotplot next to the tree, showing the number of studies each species has been used in and which stressors they were subjected to (this is for a meta-analysis). I'm using geom_facet (I've also tried facet_plot) using ggtree and treeio. The problem is that my clade highlights and labels are appearing in both panels, not just in the tree panel. I can't find a way to make them appear only in the tree panel.

My current code for the tree plot (phylogram) looks like this:

`treegraph <- ggtree(tree, branch.length = "none") + geom_tiplab(align=TRUE, size = 3) +
  scale_x_continuous(expand=expansion(0.5)) + 
  geom_hilight(node = 47, fill = "salmon", alpha = 0.4) + 
  geom_cladelab(node = 47, label = " Pomacentridae", offset = 6,
            fontsize = 3) +
  geom_hilight(node = 51, fill = "orange", alpha = 0.4) + 
  geom_cladelab(node = 51, label = " Atherinidae", offset = 6,
            fontsize = 3) + 
  geom_hilight(node = 50, fill = "yellow", alpha = 0.4) + 
  geom_cladelab(node = 50, label = " Poeciliidae", offset = 6,
            fontsize = 3) + 
  geom_hilight(node = 55, fill = "green", alpha = 0.4) + 
  geom_cladelab(node = 55, label = " Gadidae", offset = 6,
            fontsize = 3) + 
  geom_hilight(node = 32, fill = "cornflowerblue", alpha = 0.4) + 
  geom_cladelab(node = 32, label = " Cyprinidae", offset = 6,
            fontsize = 3) + 
  geom_hilight(node = 39, fill = "violet", alpha = 0.4) + 
  geom_cladelab(node = 39, label = " Clupeidae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 17, label = " Trypteriigidae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 18, label = " Embiotocidae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 26, label = " Kyphosidae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 25, label = " Gasterosteidae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 24, label = " Sciaenidae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 23, label = " Moronidae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 13, label = " Osmeridae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 12, label = " Salmonidae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 8, label = " Callichthyidae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 7, label = " Pangasiidae", offset = 6,
            fontsize = 3) + 
  geom_cladelab(node = 11, label = " Engraulidae", offset = 6,
            fontsize = 3)`

I'm then adding the aligned dot plot using the code:

`treegraph + geom_facet("dot", data = climate, geom = geom_point, mapping=aes(x=stressorno, size =       clim_freq), color='red3')`

The dots themselves are good but the highlights are appearing in both panels which looks weird and isn't what I want. Any help is appreciated.

0

There are 0 best solutions below