innsight_ggplot2 | R Documentation |
The S4 class innsight_ggplot2
visualizes the results of the methods
provided from the package innsight
using ggplot2. In addition, it
allows easier analysis of the results and modification of the
visualization by basic generic functions. The individual slots are for
internal use only and should not be modified.
This S4 class is a simple extension of a ggplot2 object that enables
a more detailed analysis of the results and a way to visualize the results
of models with multiple input layers (e.g., images and tabular data).
The distinction between one and multiple input layers decides the behavior
of this class, and this information is stored in the slot multiplot
.
multiplot = FALSE
)If the model passed to a method from the innsight package has only one
input layer, the S4 class innsight_ggplot2
is just a wrapper of a
single ggplot2 object. This object is stored as a 1x1 matrix in
the slot grobs
and the slots output_strips
and col_dims
contain
only empty lists because no second line of stripes describing the input
layer is needed.
Although it is an object of the class innsight_ggplot2
,
the generic function +.innsight_ggplot2 provides a ggplot2-typical usage
to modify the representation. The graphical objects are simply forwarded to
the ggplot2 object in grobs
and added using ggplot2::+.gg. In addition,
some generic functions are implemented to visualize or examine
individual aspects of the overall plot in more detail. All available
generic functions are listed below:
+
plot
,
print
and
show
(all behave the same)
[
[[
Note: In this case, the generic function [<-
is not implemented
because there is only one ggplot2 object and not multiple ones.
multiplot = TRUE
)If the passed model has multiple input layers, a ggplot2 object is
created for each data point, input layer and output node and then stored
as a matrix in the slot grobs
. During visualization, these are combined
using the function gridExtra::arrangeGrob
and corresponding strips for
the output layer/node names are added at the top. The labels, column
indices and theme for the extra row of strips are stored in the slots
output_strips
and col_dims
. The strips for the input
layer and the data points (if not boxplot) are created using
ggplot2::facet_grid in the individual ggplot2 objects of the grob matrix.
An example structure is shown below:
| Output 1: Node 1 | Output 1: Node 3 | | Input 1 | Input 2 | Input 1 | Input 2 | |---------------------------------------------------------|------------- | | | | | | grobs[1,1] | grobs[1,2] | grobs[1,3] | grobs[1,4] | data point 1 | | | | | |---------------------------------------------------------|------------- | | | | | | grobs[2,1] | grobs[2,2] | grobs[2,3] | grobs[2,4] | data point 2 | | | | |
Similar to the other case, generic functions are implemented to add
graphical objects from ggplot2, create the whole plot or select only
specific rows/columns. The difference, however, is that each entry in
each row and column is a separate ggplot2 object and can be modified
individually. For example, adds + ggplot2::xlab("X")
the x-axis label
"X" to all objects and not only to those in the last row. The generic
function [<-
allows you to replace
a selection of objects in grobs
and thus, for example, to change
the x-axis title only in the bottom row. All available
generic functions are listed below:
+
plot
,
print
and
show
(all behave the same)
[
[[
[<-
[[<-
Note: Since this is not a standard visualization, the suggested packages
'grid'
, 'gridExtra'
and 'gtable'
must be installed.
grobs
The individual ggplot2 objects arranged as a matrix (see details for more information)
multiplot
A logical value indicating whether there are multiple input layers and therefore correspondingly individual ggplot2 objects instead of one single object.
output_strips
A list containing the labels and themes of the strips
for the output nodes. This slot is only relevant if multiplot
is TRUE
.
col_dims
A list of the length of output_strips
assigning to
each strip the column index of grobs
of the associated strip.
boxplot
A logical value indicating whether the result of individual data points or a boxplot over multiple instances is displayed.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.