If you are knitting to an HTML-based format, the only supported options are
vega.height (as pixels) and
vega.embed (as a list).
If you are knitting to a non-HTML-based format, you additionally
have the options
knit_print.vegaspec(spec, ..., options = NULL)
An object to be coerced to
vegaspec, a Vega/Vega-Lite specification
list, knitr options
The biggest thing to keep in mind about a Vega visualization is that very often, the chart tells you how much space it needs, rather than than you tell it how much space it has available. In the future, it may reveal itself how to manage better this "conversation".
When knitting to an HTML-based format, the
spec is rendered as normal,
vegawidget() using the options
vega.height are passed to
height, respectively. These values are coerced to numeric,
so it is ineffective to specify a percentage. They are passed to
vw_autosize() to resize the chart, if
When knitting to an non-HTML-based format, e.g.
pdf_document, this function will convert the chart to an image, then knitr
will incorporate the image into your document. You have the additional
The supported values of
"pdf". If you
are knitting to a LaTeX format (e.g.
pdf_document) and you specify
"svg", it will be implemented as
To scale the image within your document, you can use
out.height. Because the image will already have an aspect ratio,
it is recommended to specify no more than one of these.