Skip to content

unexpected units error when plotting with small fig.width in Rmarkdown #176

Description

@ha0ye

I'm writing a function to generate network figures, and it's sometimes giving me an unusual error. I couldn't exactly place what exactly was causing the error.

The message I'm getting is:

Error in unit(x_new, "mm") : 'x' and 'units' must have length > 0
Calls: <Anonymous> ... makeContent -> makeContent.cappedpathgrob -> grob -> unit
Execution halted

which seems related to having long node names, and trying to draw nodes and edges in a certain way.

Here's a small reprex (in the form of an Rmarkdown chunk)

```{r, fig.width = 3}
df <- tibble::tribble(
    ~from,  ~to,
    "a",    "b",
    "c",    "asdfasdfasdfasdfasdfasdfadsf")

my_graph <- igraph::graph_from_data_frame(df)

ggraph(my_graph, layout = "circle") +
    geom_edge_link(start_cap = circle(0.3, "inches")) +
    geom_node_circle(aes(r = 0.08, fill = name)) +
    coord_fixed()
    ```

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions