The arguments width and height are used to override the width and height of the provided spec, if the spec does not have multiple views. The dimensions you provide describe the overall width and height of the rendered chart, including axes, labels, legends, etc.

vw_autosize(spec, width = NULL, height = NULL)

Arguments

spec

An object to be coerced to vegaspec, a Vega/Vega-Lite specification

width

integer, if specified, the total rendered width (in pixels) of the chart - valid only for single-view charts and layered charts; the default is to use the width in the chart specification

height

integer, if specified, the total rendered height (in pixels) of the chart - valid only for single-view charts and layered charts; the default is to use the height in the chart specification

Value

S3 object with class vegaspec

Details

In a Vega or Vega-Lite specification, the default interpretation of width and height is to describe the dimensions of the data rectangle, not including the space used by the axes, labels, legends, etc. When width and height are specified using autosize, the meanings of width and height change to describe the dimensions of the entire chart, including axes, labels, legends, etc.

There is an important limitation: specifying width and height is effective only for single-view and layered specifications. It will not work for specifications with multiple views (e.g. hconcat, vconcat, facet, repeat); this will issue a warning that there will be no effect on the specification when rendered.

Examples

  vw_autosize(spec_mtcars, width = 350, height = 350)