Description Usage Arguments Details Value Author(s) References See Also Examples
Methods (S3) to visualize association rules and itemsets. Implemented are several popular visualization methods including scatter plots with shading (twokey plots), graph based visualizations, doubledecker plots, etc.
Many plots can use different rendering engines including static standard plots (mostly using grid), standard plots with interactive manipulation and interactive HTML widgetbased visualizations.
1 2 3 4 5 6  ## S3 method for class 'rules'
plot(x, method = NULL, measure = "support", shading = "lift",
interactive = NULL, engine = "default", data = NULL, control = NULL, ...)
## S3 method for class 'itemsets'
plot(x, method = NULL, measure = "support", shading = NA,
interactive = NULL, engine = "default", data = NULL, control = NULL, ...)

x 
an object of class "rules" or "itemsets". 
method 
a string with value "scatterplot", "twokey plot", "matrix", "matrix3D", "mosaic", "doubledecker", "graph", "paracoord" or "grouped", "iplots" selecting the visualization method (see Details). Note that some methods may only be available for rules or itemsets. 
measure 
measure(s) of interestingness
(e.g., "support", "confidence", "lift", "order") used in the visualization. Some
visualization methods need one measure, others take a vector with two
measures (e.g., scatterplot). In some plots (e.g., graphs) 
shading 
measure of interestingness used
for the color of the points/arrows/nodes
(e.g., "support", "confidence", "lift"). The default is "lift".

interactive 
deprecated. See parameter 
control 
a list of control parameters for the plot. The available control parameters depend on the used visualization method (see Details). 
data 
the dataset (class "transactions") used to generate the rules/itemsets. Only "mosaic" and "doubledecker" require the original data. 
engine 
a string indicating the plotting engine used to
render the plot.
The "default" engine uses (mostly) grid,
but some plots can produce interactive
interactive grid visualizations using engine "interactive", or
HTML widgets using engine
"htmlwidget". These widgets can be saved as standalone web pages
(see Examples). Note that HTML widgets tend to get very slow
or unresponsive for
too many rules. To prevent this situation, the control parameter

... 
Further arguments are added for convenience to the 
Most visualization techniques are described by Bruzzese and Davino (2008),
however, we added more color shading, reordering and interactive features
(see Hahsler, 2017).
Many visualization methods take extra parameters as the control
parameter list. Although, we have tried to keep control parameters consistent, the available control parameters vary (slightly) from visualization method to visualization method. A complete list of parameters with default
values can be obtained using verbose mode. For example,
plot(rules, method = "graph", control = list(verbose = TRUE))
prints a complete list of control parameters for method "graph" (default engine).
The following visualization method are available:
This visualization method draws a two dimensional scatterplot with different measures of interestingness (parameter "measure") on the axes and a third measure (parameter "shading") is represented by the color of the points. There is a special value for shading called "order" which produces a twokey plot where the color of the points represents the length (order) of the rule.
Interactive manipulations are available. Engine "htmlwidget" is available to produce an interactive webbased visualization (uses plotly).
Arranges the association rules as a matrix with the itemsets in the antecedents
on one axis and the itemsets in the consequents on the other. The
measure of interestingness (first element of measure
) is either visualized by a color (darker means a higher value for the
measure) or as the height of a bar (engine "3d").
The control parameter reorder
takes the values
"none"
, "measure"
, "support/confidence"
, or "similarity"
and
can be used to reorder LHS and RHS of the rules differntly. The default reordering average measure
(typically lift) pushing the rules with the highest lift value to the topleft corner of the plot.
Interactive
visualizations using engine "interactive" or "htmlwidget" (via plotly)
are available.
Grouped matrixbased visualization (Hahsler and Karpienko, 2016; Hahsler 2016). Antecedents (columns) in the matrix are grouped using clustering. Groups are represented by the most interesting item (highest ratio of support in the group to support in all rules) in the group. Balloons in the matrix are used to represent with what consequent the antecedents are connected.
Interactive manipulations (zooming into groups and identifying rules) are available.
The list of control parameters for this method includes:
plot title
number of antecedent groups (default: 20)
maximal number of RHSs to show. The rest are suppressed. (default: 10)
number of LHS items shown (default: 2)
aggregation function can be any function computing a scalar from a vector (e.g., min, mean (default), median, sum, max). It is also used to reorder the balloons in the plot.
color palette (default is 100 heat colors.)
gpar()
objects used to specify color, font and font size for
different elements.
Represents the rules (or itemsets) as a graph with items as labeled vertices, and rules (or itemsets) represented as vertices connected to items using arrows. For rules, the LHS items are connected with arrows pointing to the vertex representing the rule and the RHS has an arrow pointing to the item.
Several engines are available. The default engine uses igraph (plot.igraph
and tkplot
for the interactive visualization).
...
arguments are passed on to the respective plotting function (use for color, etc.).
Alternatively, the engines "graphviz" (Rgraphviz) and "htmlwidget" (visNetwork) are available. Note that Rgraphviz has to be installed separately from http://www.bioconductor.org/.
Represents a single rule as a doubledecker or mosaic plot.
Parameter data
has to be specified to compute the needed contingency
table. No interactive version is available.
Represents the rules (or itemsets) as a parallel coordinate plot. Currently there is no interactive version available.
Experimental interactive plots (package iplots) which support selection, highlighting, brushing, etc. Currently plots a scatterplot (support vs. confidence) and several histograms. Interactive manipulations are available.
Several interactive plots return a set of selected rules/itemsets. Other plots might return other data structures. For example, graphbased plots return the graph (invisibly). Engine "htmlwidget" always returns an object of class htmlwidget.
Michael Hahsler and Sudheer Chelluboina. Some visualizations are based on the implementation by Martin Vodenicharov.
Bruzzese, D. and Davino, C. (2008), Visual Mining of Association Rules, in Visual Data Mining: Theory, Techniques and Tools for Visual Analytics, SpringerVerlag, pp. 103122.
Hahsler, M. and Karpienko, R. (2016), Visualizing Association Rules in Hierarchical Groups. Journal of Business Economics, 87(3):17335, May 2016
Hahsler, M. (2016), Grouping association rules using lift. In C. Iyigun, R. Moghaddess, and A. Oztekin, editors, 11th INFORMS Workshop on Data Mining and Decision Analytics (DMDA 2016).
Hahsler, M. (2017), arulesViz: Visualizing association rules with R. R Journal, 9(2):163175, December 2017.
plotly_arules
,
scatterplot3d
in scatterplot3d,
plot.igraph
and
tkplot
in igraph,
seriate
in seriation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144  data(Groceries)
rules < apriori(Groceries, parameter=list(support=0.001, confidence=0.8))
rules
## Scatterplot
## 
plot(rules)
## Scatterplot with custom colors
library(colorspace) # for sequential_hcl
plot(rules, control = list(col=sequential_hcl(100)))
plot(rules, col=sequential_hcl(100))
plot(rules, col=grey.colors(50, alpha =.8))
## See all control options using verbose
plot(rules, verbose = TRUE)
## Interactive plot (selected rules are returned)
## Not run:
sel < plot(rules, engine = "interactive")
## End(Not run)
## Create a html widget for interactive visualization
## Not run:
plot(rules, engine = "htmlwidget")
## End(Not run)
## Twokey plot (is a scatterplot with shading = "order")
plot(rules, method = "twokey plot")
## Matrix shading
## 
## The following techniques work better with fewer rules
subrules < subset(rules, lift>5)
subrules
## 2D matrix with shading
plot(subrules, method="matrix")
## 3D matrix
plot(subrules, method="matrix", engine = "3d")
## Matrix with two measures
plot(subrules, method="matrix", shading=c("lift", "confidence"))
## Reorder rules
plot(subrules, method="matrix", control = list(reorder = "none"))
plot(subrules, method="matrix", control = list(reorder = "support/confidence"))
plot(subrules, method="matrix", control = list(reorder = "similarity"))
## Interactive matrix plot (default interactive and as a html widget)
## Not run:
plot(subrules, method="matrix", engine="interactive")
plot(subrules, method="matrix", engine="htmlwidget")
## End(Not run)
## Grouped matrix plot
## 
plot(rules, method="grouped matrix")
plot(rules, method="grouped matrix",
col = grey.colors(10),
gp_labels = gpar(col = "blue", cex=1, fontface="italic"))
## Interactive grouped matrix plot
## Not run:
sel < plot(rules, method="grouped", engine = "interactive")
## End(Not run)
## Graphs
## 
## Graphs only work well with very few rules
subrules2 < sample(subrules, 25)
plot(subrules2, method="graph")
## Custom colors
plot(subrules2, method="graph",
nodeCol = grey.colors(10), edgeCol = grey(.7), alpha = 1)
## igraph layout generators can be used (see ? igraph::layout_)
plot(subrules2, method="graph", layout=igraph::in_circle())
plot(subrules2, method="graph",
layout=igraph::with_graphopt(spring.const=5, mass=50))
## Graph rendering using Graphviz
## Not run:
plot(subrules2, method="graph", engine="graphviz")
## End(Not run)
## Default interactive plot (using igraph's tkplot)
## Not run:
plot(subrules2, method="graph", engine = "interactive")
## End(Not run)
## Interactive graph as a html widget (using igraph layout)
## Not run:
plot(subrules2, method="graph", engine="htmlwidget")
plot(subrules2, method="graph", engine="htmlwidget",
igraphLayout = "layout_in_circle")
## End(Not run)
## Parallel coordinates plot
## 
plot(subrules2, method="paracoord")
plot(subrules2, method="paracoord", control = list(reorder=TRUE))
## Doubledecker plot
## 
## Note: only works for a single rule
oneRule < sample(rules, 1)
inspect(oneRule)
plot(oneRule, method="doubledecker", data = Groceries)
## Itemsets
## 
itemsets < eclat(Groceries, parameter = list(support = 0.02, minlen=2))
plot(itemsets)
plot(itemsets, method="graph")
plot(itemsets, method="paracoord", alpha=.5, reorder=TRUE)
## Add more quality measures to use for the scatterplot
## 
quality(itemsets) < interestMeasure(itemsets, trans=Groceries)
head(quality(itemsets))
plot(itemsets, measure=c("support", "allConfidence"), shading="lift")
## Save HTML widget as web page
## 
## Not run:
p < plot(rules, engine = "html")
htmlwidgets::saveWidget(p, "arules.html", selfcontained = FALSE)
browseURL("arules.html")
## End(Not run)
# Note: selfcontained seems to make the browser slow.

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.