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

Problem on edge colour geom_edge_link colour #142

Closed
jas1 opened this issue Jun 1, 2018 · 15 comments
Closed

Problem on edge colour geom_edge_link colour #142

jas1 opened this issue Jun 1, 2018 · 15 comments

Comments

@jas1
Copy link

jas1 commented Jun 1, 2018

Hi , first of all; Really thanks for the awsome package.
I've seen the link: https://www.data-imaginist.com/2017/announcing-ggraph/

and I really want to give a try to the faceted graph thing,

Unluckily, at the first example got stuck as I wont get the colors. ( code below )

I ve tryed in linux and windows ( info at the end )

the example

library(ggraph)
library(igraph)
graph <- graph_from_data_frame(highschool)

p <- ggraph(graph, layout = 'kk') +
geom_edge_link(aes(colour = factor(year))) +
geom_node_point() +
ggtitle('An example')

p

Session info

LINUX

R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.4 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=es_AR.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=es_AR.UTF-8 LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=es_AR.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] igraph_1.1.2 ggraph_1.0.1 ggplot2_2.2.1

loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 bindr_0.1.1 magrittr_1.5 units_0.5-1 MASS_7.3-50
[6] munsell_0.4.3 viridisLite_0.3.0 colorspace_1.3-2 R6_2.2.2 rlang_0.2.0
[11] udunits2_0.13 plyr_1.8.4 dplyr_0.7.4 tools_3.4.4 grid_3.4.4
[16] gtable_0.2.0 ggforce_0.1.2 lazyeval_0.2.0 digest_0.6.12 assertthat_0.2.0
[21] tibble_1.4.2 bindrcpp_0.2.2 gridExtra_2.3 tweenr_0.1.5 viridis_0.5.1
[26] ggrepel_0.8.0 glue_1.2.0 labeling_0.3 compiler_3.4.4 pillar_1.2.1
[31] scales_0.4.1 pkgconfig_2.0.1

WINDOWS

R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Spain.1252 LC_CTYPE=Spanish_Spain.1252 LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] igraph_1.2.1 ggraph_1.0.1 ggplot2_2.2.1

loaded via a namespace (and not attached):
[1] Rcpp_0.12.17 bindr_0.1.1 magrittr_1.5 units_0.5-1 MASS_7.3-50 tidyselect_0.2.4
[7] munsell_0.4.3 viridisLite_0.3.0 colorspace_1.3-2 R6_2.2.2 rlang_0.2.1 udunits2_0.13
[13] plyr_1.8.4 dplyr_0.7.5 tools_3.4.4 grid_3.4.4 gtable_0.2.0 ggforce_0.1.2
[19] yaml_2.1.19 lazyeval_0.2.1 digest_0.6.15 assertthat_0.2.0 tibble_1.4.2 bindrcpp_0.2.2
[25] gridExtra_2.3 purrr_0.2.5 tweenr_0.1.5 viridis_0.5.1 ggrepel_0.8.0 glue_1.2.0
[31] labeling_0.3 compiler_3.4.4 pillar_1.2.3 scales_0.5.0 pkgconfig_2.0.1

@thomasp85
Copy link
Owner

What is the issue exactly? Are you getting a plot but without colour?

@jas1
Copy link
Author

jas1 commented Jun 1, 2018

Thanks for the quick response.
Exactly, I'm not having any colour on the plots.

what i get:
image

what i expect:
image

@jas1
Copy link
Author

jas1 commented Jun 3, 2018

got it working, nevertheless i think the issue its " still open ".
tests done:

library(ggraph)
library(igraph)
graph <- graph_from_data_frame(highschool)

p <- ggraph(graph, layout = 'kk') + 
  geom_edge_link(aes(colour = factor(year))) + 
  geom_node_point() + 
  ggtitle('An example')

p

image

# --------

p2 <- ggraph(graph, layout = 'kk') + 
    geom_edge_link(aes(edge_colour = factor(year))) + 
    geom_node_point() + 
    ggtitle('An example')

p2

image

# --------


p3 <- ggraph(graph, layout = 'kk') + 
    geom_edge_link(aes(edge_colour = factor(year),colour=factor(year))) + 
    geom_node_point() + 
    ggtitle('An example')

p3

image

the difference between plot & plot 2 its the colour vs edge_colour

the difference between vs plot 3 , its that its spacified both edge_colour + colour

may be some variable override its in the code

hope it helps :D

@thomasp85
Copy link
Owner

That seems super strange. I’ve never seen this behaviour before. I’ll look into it but have some prescient priorities elsewhere at the moment

@jas1
Copy link
Author

jas1 commented Jun 3, 2018

Thanks for the quick response,
Made it to facet the graphs with colors so im not in any hurry =)
Nevertheless the behaviour its quite strange; send you the examples with the outputs as they might help you debug .

Feel free to lower the priority or if needed close. ( no suggest to close ase its weird behaviour )

keep the awsome work :D

@sjfox
Copy link

sjfox commented Jun 12, 2018

I'm actually having the exact same issue or similar issue. Reverting to version 1.0.0 doesn't fix the issue either, so I'm quite confused.

Following the first example here (https://www.data-imaginist.com/2017/ggraph-introduction-edges/) doesn't work for coloring edges. Here are three attempts:

No color

ggraph(hairball, layout = 'kk') +
geom_edge_link(aes(colour = year))

ggraph(hairball, layout = 'kk') +
geom_edge_link(aes(edge_colour = year))

Color works

ggraph(hairball, layout = 'kk') +
geom_edge_link(aes(color = year, edge_color = year))

but get this warning: "Warning: Ignoring unknown aesthetics: edge_color
Scale for 'edge_colour' is already present. Adding another scale for 'edge_colour', which will replace the existing scale."

In my personal example, I get this error: "Error in guide_train.edge_colourbar(guide, scale, output) :
unused argument (output)"

Not sure if that's related or not to the other issues...

@thomasp85
Copy link
Owner

I’m beginning to think this is due to version incompatibilities between ggraph and ggplot2 - does it persist if you downgrade to CRAN versions for both packages?

@sjfox
Copy link

sjfox commented Jun 13, 2018

That makes sense, but I'm having trouble downgrading both. When I downgrade ggplot2 to 2.0/2.1 I get this error trying to install either ggraph version: "Error : object ‘FacetWrap’ is not exported by 'namespace:ggplot2' "

Any ideas?

@thomasp85
Copy link
Owner

You need 2.2.1, which is the lavest on CRAN

@sjfox
Copy link

sjfox commented Jun 13, 2018

Ah I was confused at what you meant. I am using both of the most recent CRAN versions for ggplot2 and ggraph, and that's where the original issue is happening. I thought you were asking to try downgrading both.

@thomasp85
Copy link
Owner

One of your warnings indicated that you were using the development version of ggplot2.

Can you reproduce the issue with fresh installs from CRAN

@sjfox
Copy link

sjfox commented Jun 14, 2018

I just tried this on a code ocean capsule, and am still not getting any color to the edges. I believe those are fresh CRAN installs, but here are the versions:
ggplot2: 2.2.1
igraph: 1.2.1
ggraph: 1.0.1

@aterhorst
Copy link

I can confirm I have same problem. Can only render coloured edges using geom_edge_link(aes(edge_colour = factor(year),colour=factor(year))).

R version 3.5.0
ggplpt2 2.2.1
ggraph 1.0.1
igraph 1.2.1

@thomasp85
Copy link
Owner

This turned out to be a regression in the latest ggforce release... Installing ggforce from GitHub will solve it (I'll work on making a hotfix for the cran version as well, as the next proper ggforce release is some time away)

@DanielIAvila
Copy link

I am experiencing this exact same issue. In my graph I have specified a color under E(g)$color that I want to use, and it is not working. It is taking the default colors used in ggplot2.

I have tried both the combination and stand-alone version and it is not working. I have tried it also for the nodes and it is not working either.

ggraph(g, layout = layout_matrix) +
  geom_edge_link(aes(edge_colour=factor(E(g)$colour), colour=factor(E(g)$colour)), show.legend = FALSE) +
  geom_node_point(aes(size = size, colour = color), show.legend = FALSE)
R version 4.3.3 (2024-02-29 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

other attached packages:
 [1] lubridate_1.9.3    forcats_1.0.0      stringr_1.5.1      purrr_1.0.2       
 [5] readr_2.1.5        tidyr_1.3.1        tibble_3.2.1       tidyverse_2.0.0   
 [9] RColorBrewer_1.1-3 ggraph_2.2.1       ggplot2_3.5.0      igraph_2.0.3      
[13] jsonlite_1.8.8     readxl_1.4.3       dplyr_1.1.4        openalexR_1.3.1   

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.1   viridisLite_0.4.2  farver_2.1.1       viridis_0.6.5     
 [5] fastmap_1.1.1      tweenr_2.0.3       timechange_0.3.0   lifecycle_1.0.4   
 [9] sf_1.0-16          magrittr_2.0.3     compiler_4.3.3     rlang_1.1.3       
[13] progress_1.2.3     tools_4.3.3        utf8_1.2.4         ggsignif_0.6.4    
[17] prettyunits_1.2.0  labeling_0.4.3     graphlayouts_1.1.1 bit_4.0.5         
[21] classInt_0.4-10    curl_5.2.1         abind_1.4-5        KernSmooth_2.23-22
[25] withr_3.0.0        grid_4.3.3         polyclip_1.10-6    fansi_1.0.6       
[29] ggpubr_0.6.0       e1071_1.7-14       colorspace_2.1-0   scales_1.3.0      
[33] MASS_7.3-60.0.1    cli_3.6.2          crayon_1.5.2       generics_0.1.3    
[37] rstudioapi_0.15.0  httr_1.4.7         tzdb_0.4.0         DBI_1.2.2         
[41] cachem_1.0.8       ggforce_0.4.2      proxy_0.4-27       parallel_4.3.3    
[45] cellranger_1.1.0   vctrs_0.6.5        carData_3.0-5      car_3.1-2         
[49] hms_1.1.3          bit64_4.0.5        rstatix_0.7.2      ggrepel_0.9.5     
[53] units_0.8-5        glue_1.7.0         stringi_1.8.3      gtable_0.3.4      
[57] munsell_0.5.0      pillar_1.9.0       R6_2.5.1           tidygraph_1.3.1   
[61] vroom_1.6.5        backports_1.4.1    memoise_2.0.1      broom_1.0.5       
[65] class_7.3-22       Rcpp_1.0.12        gridExtra_2.3      pkgconfig_2.0.3

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

5 participants