labels are cut off on the sides
lvaudor opened this issue · 2 comments
Hi,
I'm trying to use ggraph to display some moderately complex graphs for which it is crucial that I can display nodes' labels.
I cannot figure out a way to have the labels not cut off on the sides.
Here is an example:
tib=tibble::tibble(c("blablablabla","kirikikiki"),
c("kirikikiki","pioupioupiou")
tibgraph=tidygraph::as_tbl_graph(tib)
graphplot=ggraph::ggraph(tibgraph, layout="fr")+
ggraph::geom_edge_link()+
ggraph::geom_node_label(aes(label=name))
graphplot
I don't wish to use repel=TRUE because I would like central labels not to be moved from their initial positions. So I've just been looking for a solution of the kind ggplot2::xlim() or ggplot2::scale_x_continuous(), setting limits manually (I generate the layout, then get x coordinates, then expand their range by a factor) but I'm not getting anywhere with that, as I get the following error message:
Vectorized input to element_text()
is not officially supported.
ℹ Results may be unexpected or may change in future versions of ggplot2.
What am I missing here?
Thanks in advance,
Lise
You can solve this by turning off clipping in the coordinate system (coord_cartesian(clip = "off")
) and setting a wider margin on the plot (theme(plot.margin=margin(1, 1, 1, 1, "cm"))
)
I'm unsure about what you did to elicit the warning above so I can't comment on that, but expanding the range of the scales should also work
Yes!!
Thanks a lot for your (very quick) help, it did the trick!