Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
437 views
in Technique[技术] by (71.8m points)

r - 图形:如何更改默认的fill = depth调色板颜色(R ggraph: How to change the default fill=depth palette colours)

Very small question, don't know why I can't see the answer myself.

(很小的问题,不知道为什么我自己看不到答案。)

I've build a plot in R with the commands:

(我使用以下命令在R中构建了一个绘图:)

library(ggraph)
library(igraph)
library(dplyr)
edges <-read.table('edges.txt',header=TRUE,sep='')
vertices <-read.table('vertices.txt',header=TRUE,sep='')
mygraph <- graph_from_data_frame( edges, vertices=vertices )
ggraph(mygraph, layout = 'circlepack', weight=connection_number) +  geom_node_circle() +theme_void() + geom_node_circle(aes(fill =depth))

Output is exactly as expected, except I can't work out two basic things:

(输出完全符合预期,但我无法解决两个基本问题:)

  1. How to change the colour palette from various shades of blue depending on depth (the default), to various shades of green depending on depth.

    (如何将调色板从取决于深度的各种蓝色阴影(默认值)更改为取决于深度的各种绿色阴影。)

  2. How to add labels to the nodes, I was trying:

    (我正在尝试如何向节点添加标签:)

ggraph(mygraph, layout = 'circlepack', weight=connection_number) + geom_node_circle() +theme_void() + geom_node_circle(aes(fill =depth) + geom_text(aes(label = paste(name))))

But it just prints a black and white outline shape (ie removes the colours that I put in);

(但是它只是打印出黑白轮廓形状(即删除我放入的颜色);)

I found this answer, but I don't want to define every single shade, I just want to say 'use various shades of green instead of the various shades of blue that are currently used'.

(我找到了这个答案,但是我不想定义每个阴影,我只是想说“使用各种绿色阴影,而不是当前使用的各种蓝色阴影”。)

  ask by Slowat_Kela translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...