View source: R/layout_treemap.R
layout_tbl_graph_treemap | R Documentation |
A treemap is a space filling hierarchical layout that maps nodes to rectangles. The rectangles of the children of a node is packed into the rectangle of the node so that the size of a rectangle is a function of the size of the children. The size of the leaf nodes can be mapped arbitrarily (defaults to 1). Many different algorithms exists for dividing a rectangle into smaller bits, some optimizing the aspect ratio and some focusing on the ordering of the rectangles. See details for more discussions on this. The treemap layout was first developed by Ben Shneiderman for visualizing disk usage in the early '90 and has seen many improvements since.
layout_tbl_graph_treemap(
graph,
algorithm = "split",
weight = NULL,
circular = FALSE,
sort.by = NULL,
direction = "out",
height = 1,
width = 1
)
graph |
A |
algorithm |
The name of the tiling algorithm to use. Defaults to 'split' |
weight |
An optional node variable to use as weight. Will only affect the weight of leaf nodes as the weight of non-leaf nodes are derived from their children. |
circular |
Logical. Should the layout be transformed to a circular representation. Ignored. |
sort.by |
The name of a node variables to sort the nodes by. |
direction |
The direction of the tree in the graph. |
height |
The height of the bounding rectangle |
width |
The width of the bounding rectangle |
Different approaches to dividing the rectangles in a treemap exists; all with their strengths and weaknesses. Currently only the split algorithm is implemented which strikes a good balance between aspect ratio and order preservation, but other, more well-known, algorithms such as squarify and slice-and-dice will eventually be implemented.
Algorithms
Split (default)
The Split algorithm was developed by Bjorn Engdahl in order to address the downsides of both the original slice-and-dice algorithm (poor aspect ratio) and the popular squarify algorithm (no ordering of nodes). It works by finding the best cut in the ordered list of children in terms of making sure that the two rectangles associated with the split will have optimal aspect ratio.
A data.frame with the columns x
, y
, width
,
height
, leaf
, depth
, circular
as well as any
information stored as node variables in the tbl_graph object.
Treemap is a layout intended for trees, that is, graphs where nodes only have one parent and zero or more children. If the provided graph does not fit this format an attempt to convert it to such a format will be made.
Engdahl, B. (2005). Ordered and unordered treemap algorithms and their applications on handheld devices. Master's Degree Project.
Johnson, B., & Ben Shneiderman. (1991). Tree maps: A Space-Filling Approach to the Visualization of Hierarchical Information Structures. IEEE Visualization, 284-291. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1109/VISUAL.1991.175815")}
Other layout_tbl_graph_*:
layout_tbl_graph_auto()
,
layout_tbl_graph_backbone()
,
layout_tbl_graph_cactustree()
,
layout_tbl_graph_centrality()
,
layout_tbl_graph_circlepack()
,
layout_tbl_graph_dendrogram()
,
layout_tbl_graph_eigen()
,
layout_tbl_graph_fabric()
,
layout_tbl_graph_focus()
,
layout_tbl_graph_hive()
,
layout_tbl_graph_htree()
,
layout_tbl_graph_igraph()
,
layout_tbl_graph_linear()
,
layout_tbl_graph_manual()
,
layout_tbl_graph_matrix()
,
layout_tbl_graph_metro()
,
layout_tbl_graph_partition()
,
layout_tbl_graph_pmds()
,
layout_tbl_graph_sf()
,
layout_tbl_graph_stress()
,
layout_tbl_graph_unrooted()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.