pmur002 / gridgraphics

Redraw base graphics as grid graphics
33 stars 8 forks source link

igraph plot with NA labels for edges #14

Open marcosmolla opened 5 years ago

marcosmolla commented 5 years ago

Hi, I ran into an issue with igraph in combination with cowplot.

I tried to plot a simple igraph network and found that there were NA labels added along the network edges. I first filed this under the cowplot package (see this issue here), but @clauswilke recommend to file it here. Any recommendations?

Thanks everyone!!

Here is my code example:


library(igraph)
library(cowplot)
net<- graph_from_literal(A-B, A-C, A-D,
                         B-E,B-F,
                         C-G,G-H)

net_plot <- ~{
  par(mar=c(0,0,0,0)+.1)
  plot(net, vertex.label.color="white", layout=layout_as_tree(net,root=1), edge.color="black", margin=c(0,0,0,0))
}

save_plot(ggdraw(net_plot), filename="~/Desktop/tst.pdf",base_height=5, base_width=6)```
pmur002 commented 5 years ago

That goes surprisingly deep. Turns out that grid::grid.text() is the culprit. I will fix that, but it will not be released until next year, so in the meantime I have also placed a fix in 'gridGraphics' (0.4-2), which should be available here (on github). Does that work for you ?

marcosmolla commented 5 years ago

I just installed the github version and yes that worked. Fantastic!! Thank you!

pmur002 commented 5 years ago

Just FYI, turns out that other code ('ggplot2') is relying on 'grid' drawing "NA" for grid.text(NA ), so this is likely to remain a 'gridGraphics' fix.