绘图数据。树,如何自定义

发布于 2025-01-20 16:14:26 字数 1239 浏览 0 评论 0 原文

我想自定义我的 data.tree。问题是我需要每个节点的箭头来按顺序显示我的“薪水”。 这正是您输入 print(data.tree) 时获得的格式。

解释一下:

Chef <- Node$new("Chef")
Chef2 <- Chef$AddChild("Chef2")
Manager1 <- Chef2$AddChild("Manager1")
Manager2 <- Chef2$AddChild("Manager2")
Manager3 <- Chef2$AddChild("Manager3")
employee1 <- Manager1$AddChild("employee1")
employee2 <- Manager1$AddChild("employee2")
employee3 <- Manager2$AddChild("employee3")
employee4 <- Manager2$AddChild("employee4")
employee5 <- Manager2$AddChild("employee5")
employee6 <- Manager3$AddChild("employee6")
employee7 <- Manager3$AddChild("employee7")
employee8 <- Manager3$AddChild("employee8")

Salary <- c("100000", "50000", "25000", "25000", "3000", "90000", "20000", "1000", "10000", "5000", "1500", "5000", "3000")

Chef <- ToDataFrameTree(Chef, "pathString")
Chef <- as.data.frame(Chef)
Chef$Salary <- Salary
Chef <- as.Node(Chef)


print(Chef, "Salary")
plot(Chef)

如果我可以将其可视化,使其看起来像这样,那就太好了:

print(Chef,

但是我只管理这样的东西...

plot

我知道描述起来有点复杂,但如果有人可以的话帮助,我将不胜感激。

I would like to customize my data.tree. The problem is that I would need an arrow from each node to show me my "Salary" in order.
It would be exactly the format you get when you type print(data.tree) .

To explain:

Chef <- Node$new("Chef")
Chef2 <- Chef$AddChild("Chef2")
Manager1 <- Chef2$AddChild("Manager1")
Manager2 <- Chef2$AddChild("Manager2")
Manager3 <- Chef2$AddChild("Manager3")
employee1 <- Manager1$AddChild("employee1")
employee2 <- Manager1$AddChild("employee2")
employee3 <- Manager2$AddChild("employee3")
employee4 <- Manager2$AddChild("employee4")
employee5 <- Manager2$AddChild("employee5")
employee6 <- Manager3$AddChild("employee6")
employee7 <- Manager3$AddChild("employee7")
employee8 <- Manager3$AddChild("employee8")

Salary <- c("100000", "50000", "25000", "25000", "3000", "90000", "20000", "1000", "10000", "5000", "1500", "5000", "3000")

Chef <- ToDataFrameTree(Chef, "pathString")
Chef <- as.data.frame(Chef)
Chef$Salary <- Salary
Chef <- as.Node(Chef)


print(Chef, "Salary")
plot(Chef)

It would be great if I can viusalize it so that it it looks like this:

print(Chef, "Salary")

However I only manage something like this...

plot

I know it's a bit complicated described, but if anyone can help, I would appreciate it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

弱骨蛰伏 2025-01-27 16:14:26

当您使用 diagrammer 标记您的问题时,一种选择是使用 Mermaid.js。

1. 打开Mermaid 实时编辑器

Mermaid 甚至允许非程序员通过 Mermaid 实时编辑器轻松创建详细信息和图表。

2. 基本结构

代码部分,输入:

flowchart LR
   Chef --> Chef2
   Chef2 --> Manager1 & Manager2 & Manager3
   Manager1 -->   employee1 & employee2
   Manager2 -->   employee3 & employee4 & employee5
   Manager3 -->   employee6 & employee7 & employee8

3. 查看基本图表

您将在编辑器的右侧看到一个图表(如下所示)。

4. 修改以获得所需的图表

为每个人添加工资标签,清除代码部分,然后在下面输入新的代码:

flowchart LR

subgraph A["100,000"]
direction LR
Chef
end

subgraph B["50,000"]
direction LR
Chef2
end

subgraph C["25,000"]
direction LR
Manager1
end

subgraph D["90,000"]
direction LR
Manager2
end

subgraph E["5,000"]
direction LR
Manager3
end

subgraph F["25,000"]
direction LR
employee1
end

subgraph G["3,000"]
direction LR
employee2
end

subgraph H["20,000"]
direction LR
employee3
end

subgraph I["1,000"]
direction LR
employee4
end

subgraph J["10,000"]
direction LR
employee5
end

subgraph K["15,000"]
direction LR
employee6
end

subgraph L["5,000"]
direction LR
employee7
end

subgraph M["3,000"]
direction LR
employee8
end

Chef --> Chef2
Chef2 --> Manager1 & Manager2 & Manager3
Manager1 -->   employee1 & employee2
Manager2 -->   employee3 & employee4 & employee5
Manager3 -->   employee6 & employee7 & employee8

您将在右侧看到更新后的图表 编辑器的手边(如下)。
输入图片此处描述

5. 下载首选图表

如果您对它感到满意,请选择首选格式并下载图表。

As you tagged your question with diagrammer, one option is to use Mermaid.js.

1. Open Mermaid Live Editor

Mermaid allows even non-programmers to easily create detailed and diagrams through the Mermaid Live Editor.

2. Basic structure

In the </>code section, enter:

flowchart LR
   Chef --> Chef2
   Chef2 --> Manager1 & Manager2 & Manager3
   Manager1 -->   employee1 & employee2
   Manager2 -->   employee3 & employee4 & employee5
   Manager3 -->   employee6 & employee7 & employee8

3. Review the basic graph

You will see a graph on the right-hand side of the editor (as below).

enter image description here

4. Modify to get the desired graph

Add wage label to each person, clear the </>code section, and enter the new code below:

flowchart LR

subgraph A["100,000"]
direction LR
Chef
end

subgraph B["50,000"]
direction LR
Chef2
end

subgraph C["25,000"]
direction LR
Manager1
end

subgraph D["90,000"]
direction LR
Manager2
end

subgraph E["5,000"]
direction LR
Manager3
end

subgraph F["25,000"]
direction LR
employee1
end

subgraph G["3,000"]
direction LR
employee2
end

subgraph H["20,000"]
direction LR
employee3
end

subgraph I["1,000"]
direction LR
employee4
end

subgraph J["10,000"]
direction LR
employee5
end

subgraph K["15,000"]
direction LR
employee6
end

subgraph L["5,000"]
direction LR
employee7
end

subgraph M["3,000"]
direction LR
employee8
end

Chef --> Chef2
Chef2 --> Manager1 & Manager2 & Manager3
Manager1 -->   employee1 & employee2
Manager2 -->   employee3 & employee4 & employee5
Manager3 -->   employee6 & employee7 & employee8

You will see an updated graph on the right-hand side of the editor (as below).
enter image description here

5. Download the preferred graph

If you are happy with it, choose the preferred format and download the graph.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文