ggtree
ggtree copied to clipboard
Independent adjustment of picture and line transparency when using PhyloPic/Images and align=true parameter
trafficstars
When using geom_tiplab(), it would be useful to adjust the transparency of pictures and lines separately.
For example, when using:
test_tree <- ggtree(newick.tree) %<+% metadata +
geom_tiplab(image=df_sorted$uid,
geom="phylopic",
size = ifelse(df_sorted$uid == "6e42ac62-37f4-458c-bf44-3f7decb1f14e", 0.025, 0.05),
alpha= ifelse(df_sorted$name == "NC_004290.1" | df_sorted$name == "NC_000936.1" | df_sorted$name == "NC_005040.1", 0.4, 0.8),
offset = 1.5,
align=TRUE) +
xlim(0,5.2) +
geom_tiplab(
aes(label=Full.Name),
color="black",
geom="label",
fill = "white",
label.size = 0
)
I expect the alpha= parameter to adjust the transparency of the picture. But instead it adjusts the transparency of the line, since I have the align=TRUE parameter active.
In documentation of the geom_tiplab() function I did not find a solution to this problem. On the contrary, I was proved that it is not a bug, but a feature:
The following parameters for geom="image" or geom="phylopic".
- `image` the image file path for geom='image', but when geom='phylopic', it should be the uid of phylopic databases.
- `size` the image size, defaults to 0.05.
- `colour` the color of image, defaults to NULL.
- `alpha` the transparency of image, defaults to 0.8.
The following parameters for the line when align = TRUE.
- `colour` the colour of line, defaults to 'black'.
- `alpha` the transparency of line, defaults to NA.
- `arrow` specification for arrow heads, as created by arrow(), defaults to NULL.
- `arrow.fill` fill color to usse for the arrow head (if closed), defaults to 'NULL', meaning use 'colour' aesthetic.
I just want to adjust the transparency (and color too) of pictures separately from the line :(