Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow different end_shapes to be passed to geom_edge_span #371

Open
nicoblokker opened this issue May 20, 2024 · 0 comments
Open

Allow different end_shapes to be passed to geom_edge_span #371

nicoblokker opened this issue May 20, 2024 · 0 comments

Comments

@nicoblokker
Copy link

Hi,

It would be helpful to have the capability of passing a vector of shapes to geom_edge_span instead of a single element. This functionality was available in a previous version (2.0.5), I recall.

library(ggraph)
#> Loading required package: ggplot2
graph <- tidygraph::create_notable('zachary')

# single end_shape works fine
ggraph(graph, 'fabric', sort.by = node_rank_fabric()) + 
  geom_node_range(colour = 'grey') + 
  geom_edge_span(end_shape = 'square') + 
  coord_fixed()

# multiple shapes cause an error
ggraph(graph, 'fabric', sort.by = node_rank_fabric()) + 
  geom_node_range(colour = 'grey') + 
  geom_edge_span(end_shape = c('square', 'circle', 'cross')) + 
  coord_fixed() 
#> Error in `geom_edge_span()`:
#> ! Problem while converting geom to grob.
#> ℹ Error occurred in the 2nd layer.
#> Caused by error in `if (is.na(end_shape)) ...`:
#> ! the condition has length > 1
Second Image First Image

The right graph was created by modifying R/geom_edge.R to support conditions longer than 1:

# line 318
if (is.na(end_shape)) return(panel)
if (all(is.na(end_shape))) return(panel)

Created on 2024-05-20 with reprex v2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant