The elements are positioned as following:
on top of the plot
title
subtitle
legend, if positioned on top of the plot
facet title
at the bottom of the plot
label for the x-axis
legend, if positioned on the bottom of the plot
caption
Margins are computed based on the presence
of these elements.
Only one line is counted for the legend,
as plotly will extend the margin
if necessary for the legend (for bottom legend).
getPositionAndMargins(
title = NULL,
subtitle = NULL,
xLab = NULL,
caption = NULL,
facet = FALSE,
includeLegend = TRUE,
legendPosition = "right"
)
List with:
'margin': List with bottom ('t') and top ('t') margins in pixels
'position': List with position of the following plot elements:
on top of the plot: subtitle and legend
(if positioned at the top).
The position is defined as the distance in pixels
from the top of the plotting area to the bottom
of the element (yanchor = 'bottom'
)
at the bottom of the plot: caption, xLab
and legend (if positioned at the bottom).
The position is defined as the distance in pixels
from the bottom of the plotting area to the top
of the element (yanchor = 'top'
)
Especially, the legend should be positioned with
anchor 'top' such as the margins are automatically
expanded if the legend contains multiple rows.
String with title for the plot.
String with subtitle.
The subtitle is included at the top left of the plot,
below the title.
String with label for xVar
.
String with caption.
The caption is included at the bottom right of the plot.
Please note that this might overlap with
vertical or rotated x-axis labels.
Logical, if TRUE the plot contains facets.
Logical, if TRUE (by default) a legend is available in the plot.
String with position of the legend, among: 'top'/'left'/'bottom'/'right', 'right' by default.
Laure Cougnaud