fix(logo): reserve a logo band, keep patchwork panels, and preserve logo aspect (#20)
The logo gets its own band (logo_height inches) instead of negative margins, so captions are no longer clipped. Patchwork compositions go through patchworkGrob() so every panel survives. font_scale defaults to 1. make_logo_grob() sizes by height so the logo keeps its shape on any canvas. Closes #20 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6e3ba2fb4
commit
0561df4221
6 files changed
+171
-72
No files matched your search
+17
-9
@@ -8,29 +8,37 @@ add_logo(
|
||||
plot,
|
||||
logo,
|
||||
margin_param = NULL,
|
||||
font_scale = 1.1,
|
||||
position = c("bottom-right", "bottom-left", "top-right", "top-left")
|
||||
font_scale = 1,
|
||||
position = c("bottom-right", "bottom-left", "top-right", "top-left"),
|
||||
logo_height = 0.5
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{plot}{a ggplot2 grob}
|
||||
\item{plot}{a ggplot2 object, or a patchwork composition}
|
||||
|
||||
\item{logo}{a logo grob created by make_logo_grob()}
|
||||
|
||||
\item{margin_param}{a numeric specifying what margin to add or subtract to align the logo}
|
||||
\item{margin_param}{Optional numeric. Replaces the plot margin (in points)
|
||||
on the side next to the logo. `NULL` (default) leaves the plot's margins
|
||||
alone.}
|
||||
|
||||
\item{font_scale}{Numeric. Multiplicative scaling factor applied to text
|
||||
sizes before composing the plot with the logo. Default `1.1` inflates
|
||||
text by ~10 \% to compensate for the viewport shrinkage caused by
|
||||
[gridExtra::arrangeGrob()]. Set to `1` to disable.}
|
||||
\item{font_scale}{Numeric. Multiplicative scaling factor applied to the
|
||||
base text size before composing. Default `1` leaves typography unchanged.}
|
||||
|
||||
\item{position}{Character. Corner placement for the logo: `"bottom-right"`
|
||||
(default), `"bottom-left"`, `"top-right"`, or `"top-left"`. Controls
|
||||
whether the logo is placed above or below the plot.}
|
||||
|
||||
\item{logo_height}{Numeric. Height in inches of the band reserved for the
|
||||
logo. Default `0.5`.}
|
||||
}
|
||||
\value{
|
||||
a grob with a logo attached to it ready to plot
|
||||
}
|
||||
\description{
|
||||
Add a logo to a ggplot2 object
|
||||
The logo gets its own band of reserved height (`logo_height`, in inches)
|
||||
below or above the plot, so it cannot overlap the plot's caption or push
|
||||
anything off the canvas. Patchwork compositions are converted with
|
||||
[patchwork::patchworkGrob()] so every panel and the
|
||||
[patchwork::plot_annotation()] survive.
|
||||
}
|
||||
Reference in new issue
Block a user