View source: R/plotting_util.bare.R
coord_justif | R Documentation |
Calculate coordinates and h|vjust values for entry text strings, to achieve the desired justification and alignment with respect to cell boundaries. This is an internal utility function, not intended to be called by package users.
coord_justif(df, x0, x1, y0, y1, size, align=df$align)
df |
Data frame with one row per entry. Required columns are |
x0 , x1 , y0 , y1 |
Numeric vectors with one element per entry, giving the coordinates (in mm) of the boundaries of the cell(s) containing each entry. Note that the origin is at the top left of the table. |
size |
Data frame with one row per entry, and columns |
align |
Optional numeric vector with one element per entry. It specifies
horizontal alignment of multiple lines within an entry *with respect to
each other*. 0 means all lines in the entry are aligned at their left
edge ("left justified"), 1 means they are all aligned at their right edge
("right justified"), 0.5 means they are aligned at their centers. The
default is to use column |
The need to jointly calculate x
, y
, gg_hjust
, and
gg_vjust
is due to a difference between tablesgg
and
ggplot2
in their interpretations of text justification.
ggplot2
interprets justification parameters as indicating position
of text relative to the (x,y) coordinates used to draw the text: 0 means
to the right/above (x,y), 1 means to the left/below (x,y).
tablesgg
interprets justification parameters as position relative
to the boundaries of the table cell(s) containing the entry text: 0 means
at the left/top boundary, 1 means at the right/bottom boundary.
This function takes cell boundary coordinates x0
, x1
,
y0
, y1
and tablesgg
-type justification parameters and
converts them to the ggplot2
-type (x,y) coordinates and
justification parameters. In doing so it is also necessary to take any
text rotation (specified by graphical property angle
) into account.
Values provided to geom_*
functions should be x
, y
,
hjust=gg_hjust
, and vjust=gg_vjust
. If the geom_*
function has an halign
argument (e.g., for geom_textbox
),
set it to gg_hjust
.
Justification values in [0, 1] will never position text closer to cell
boundaries than the padding specified by df$hpad
and
df$vpad
.
Data frame with one row per row of df
. Columns are:
x , y |
Coordinates to give to a |
gg_hjust , gg_vjust |
|
entrySize_mm
, calc_rcsize
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.