chickadee » ggplot » make-pdf-backend

make-pdf-backend filename width height #!key (pdf-version 1.4) (compress? #t)procedure

Create a PDF backend writing to filename. width and height are the PDF page dimensions in points (72 pt = 1 inch; A4 portrait = 595 × 842 pt).

pdf-version
"1.4" (default) or "1.3". PDF 1.4 enables
 constant alpha (transparency) through {{ExtGState}} resources,
 applied only when a color actually carries fractional alpha. Under
 {{"1.3"}} alpha is never requested and all colors draw fully opaque.
compress?
when true (default), content streams are written
 with {{FlateDecode}} compression.

PDF pages are natively bottom-left origin with Y increasing upward — the same convention the gg protocol uses throughout — so the user-to-device mapping is a plain scale-and-offset with no Y-flip. Text is drawn with the 14 standard Type1 fonts (Helvetica, Times, and Courier families); free-form family strings that don't match one of these fall back to Helvetica, with glyph widths taken from the pdf-font AFM tables.

(import gg-plot)

(define p (ggplot data (aes #:x 'x #:y 'y)
            (layer-point #:size 6)
            (theme-minimal)))

;; via ggsave (format inferred from the .pdf extension)
(ggsave p "plot.pdf" #:width 595 #:height 842)

;; or explicitly, via render-plot
(import gg-backend-pdf)
(render-plot p (make-pdf-backend "plot.pdf" 595 842))