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

linetype in geom_node_circle not being mapped correctly #374

Open
juliette-cooke opened this issue Jul 2, 2024 · 1 comment
Open

linetype in geom_node_circle not being mapped correctly #374

juliette-cooke opened this issue Jul 2, 2024 · 1 comment

Comments

@juliette-cooke
Copy link

Hi, I'm trying to set linetypes dynamically in a circle pack plot using geom_node_circle. The problem is the linetype aes is being swapped: those I assign "dashed" end up having a solid outline, and those I assign "solid" have a dashed outline. This does not happen for the fill aes for example.

Here is a reproducible example, where the blue circles are supposed to be those with a dashed line.

edges <- flare$edges
vertices <- flare$vertices %>% mutate(linetype = ifelse(size<3000, "dashed", "solid"),
                                      size_thr = ifelse(size<3000, "small", "large"))
mygraph <- graph_from_data_frame( edges, vertices=vertices )
ggraph(mygraph, layout = 'circlepack', weight=size) + 
  geom_node_circle(aes(linetype=linetype, fill=size_thr)) +
  theme_void()+
  coord_equal()

image

@schochastics
Copy link
Contributor

@juliette-cooke you can fix this with scale_linetype_manual

library(ggraph)
library(dplyr)
library(igraph)

edges <- flare$edges
vertices <- flare$vertices  |>  mutate(linetype = ifelse(size<3000, "dashed", "solid"),
                                      size_thr = ifelse(size<3000, "small", "large"))
mygraph <- graph_from_data_frame( edges, vertices=vertices )

ggraph(mygraph, layout = 'circlepack', weight=size) + 
  geom_node_circle(aes(linetype = linetype, fill=size_thr)) +
  scale_linetype_manual(values = c("solid"="solid","dashed"="dashed"))+
  theme_void()+
  coord_equal()

Created on 2024-10-09 with reprex v2.1.1

But there seems to be several other (related?) issues with geom_node_circle():

?geom_node_circle() doesn't mention linetype as a mapping parameter. It mentions shape, with s actually not supported. Using it produces an error.

I also cannot explain this behavior:

library(ggraph)
library(dplyr)
library(igraph)

edges <- flare$edges

# renaming attribute values
vertices <- flare$vertices |> mutate(
    linetype = ifelse(size < 3000, "foo", "bar"),
    size_thr = ifelse(size < 3000, "fizz", "buzz")
)
mygraph <- graph_from_data_frame(edges, vertices = vertices)

ggraph(mygraph, layout = "circlepack", weight = size) +
    geom_node_circle(aes(linetype = linetype, fill = size_thr)) +
    theme_void() +
    coord_equal()

Created on 2024-10-09 with reprex v2.1.1

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

2 participants